Beispiel #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);
 }
        private bool DeleteFromDB(int id)
        {
            try
            {
                IFileService                   _fileService          = new SCA.BusinessLib.Utility.FileService();
                ILogRecorder                   logger                = null;
                DBFileVersionManager           dbFileVersionManager  = new DBFileVersionManager(TheController.Project.SavePath, logger, _fileService);
                IDBFileVersionService          _dbFileVersionService = dbFileVersionManager.GetDBFileVersionServiceByVersionID(DBFileVersionManager.CurrentDBFileVersion);
                ILinkageConfigGeneralDBService generalDBService      = new SCA.DatabaseAccess.DBContext.LinkageConfigGeneralDBService(_dbFileVersionService);


                if (generalDBService.DeleteGeneralLinkageConfigInfo(id))
                {
                    if (BusinessLib.ProjectManager.GetInstance.MaxIDForGeneralLinkageConfig == id) //如果最大ID等于被删除的ID,则重新赋值
                    {
                        LinkageConfigGeneralService generalService = new LinkageConfigGeneralService(TheController);
                        BusinessLib.ProjectManager.GetInstance.MaxIDForGeneralLinkageConfig = generalService.GetMaxID();
                    }
                }
            }
            catch (Exception ex)
            {
                return(false);
            }
            return(true);
        }
Beispiel #3
0
 public bool SaveToDB()
 {
     try
     {
         ILogRecorder                    logger                = null;
         IFileService                    fileService           = new SCA.BusinessLib.Utility.FileService();
         DBFileVersionManager            dbFileVersionManager  = new DBFileVersionManager(TheController.Project.SavePath, logger, fileService);
         IDBFileVersionService           _dbFileVersionService = dbFileVersionManager.GetDBFileVersionServiceByVersionID(SCA.BusinessLogic.DBFileVersionManager.CurrentDBFileVersion);
         ILinkageConfigStandardDBService dbMixedService        = new LinkageConfigStandardDBService(_dbFileVersionService);
         dbMixedService.AddStandardLinkageConfigInfo(TheController.StandardConfig);
     }
     catch
     {
         return(false);
     }
     return(true);
 }
Beispiel #4
0
 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);
 }
Beispiel #5
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);
 }
Beispiel #6
0
        public void ComfirmExecute()
        {
            this.ErrorMessagePromptImportFilePath = "";
            this.ErrorMessagePromptName           = "";
            this.ErrorMessagePromptSaveFilePath   = "";
            bool          verifyFlag    = true;
            ProjectConfig projectConfig = new ProjectConfig();
            Dictionary <string, RuleAndErrorMessage> dictRule = projectConfig.GetProjectInfoRegularExpression();
            RuleAndErrorMessage rule = dictRule["Name"];
            Regex exminator          = new Regex(rule.Rule);

            if (!string.IsNullOrEmpty(ProjectName))
            {
                if (!exminator.IsMatch(ProjectName))
                {
                    ErrorMessagePromptName = rule.ErrorMessage;
                    verifyFlag             = false;
                }
            }
            else
            {
                ErrorMessagePromptName = "请输入工程名称";
                verifyFlag             = false;
            }
            if (string.IsNullOrEmpty(ImportedFilePath))
            {
                ErrorMessagePromptImportFilePath = "请选择有效导入文件路径";
                verifyFlag = false;
            }
            if (string.IsNullOrEmpty(SavedFilePath))
            {
                ErrorMessagePromptSaveFilePath = "请选择有效文件存储路径";
                verifyFlag = false;
            }
            if (verifyFlag)
            {
                IFileService         _fileService         = new FileService();
                ILogRecorder         _logRecorder         = null;
                string               strImportedFilePath  = this.ImportedFilePath;
                string               strExtentionName     = strImportedFilePath.Substring(strImportedFilePath.LastIndexOf(".") + 1);
                DBFileVersionManager dbFileVersionManager = new DBFileVersionManager(this.ImportedFilePath, _logRecorder, _fileService);
                //取得某一系列的数据文件操作服务(4,5,6 系列没有项目,7开始有项目信息,以文件扩展名作为划分依据)
                IDBFileVersionService dbFileVersionService = dbFileVersionManager.GetDBFileVersionServiceByExtentionName(strExtentionName);
                //取得文件版本
                int fileVersion = dbFileVersionService.GetFileVersion();
                dbFileVersionService = dbFileVersionManager.GetDBFileVersionServiceByVersionID(fileVersion);
                //取得项目信息
                ProjectModel project = dbFileVersionService.GetProject(1);
                project.Name     = this.ProjectName;                                 //以当前设置的名称作为项目名
                project.SavePath = this.SavedFilePath + "\\" + project.Name + ".nt"; //以当前设置的路径作为项目的存储路径
                IControllerOperation controllerOperation = null;
                //取得项目下所有控制器信息
                List <ControllerModel> lstController = dbFileVersionService.GetControllersByProject(project);
                int             dataFileVersion      = 0;     //数据文件版本
                ControllerModel controller           = null;
                foreach (var controllerInfo in lstController) //取得控制器操作服务
                {
                    if (project.FileVersion == -1)            //4,5,6版本文件无项目信息
                    {
                        project.FileVersion = controllerInfo.FileVersion;
                    }
                    switch (controllerInfo.Type)
                    {
                    case ControllerType.FT8000:
                        controllerOperation = new ControllerOperation8000();
                        break;

                    case ControllerType.FT8003:
                        controllerOperation = new ControllerOperation8003();
                        break;

                    case ControllerType.NT8001:
                        controllerOperation = new ControllerOperation8001();
                        break;

                    case ControllerType.NT8007:
                        controllerOperation = new ControllerOperation8007();
                        break;

                    case ControllerType.NT8021:
                        controllerOperation = new ControllerOperation8021();
                        break;

                    case ControllerType.NT8036:
                        controllerOperation = new ControllerOperation8036();
                        break;
                    }
                    if (controllerOperation != null)                                                                                             //合法控制器类型
                    {
                        dataFileVersion      = Convert.ToInt32(project.FileVersion);                                                             //取得当前项目文件版本号
                        dbFileVersionService = dbFileVersionManager.GetDBFileVersionServiceByVersionID(dataFileVersion);                         //取得当前文件的数据文件服务
                        //controllerInfo = controllerOperation.OrganizeControllerInfoFromOldVersionSoftwareDataFile(oldVersionService);
                        controller = controllerOperation.OrganizeControllerInfoFromSpecifiedDBFileVersion(dbFileVersionService, controllerInfo); //取得组织完成的控制器信息
                    }
                    if (controller != null)                                                                                                      //将组织完成的信息增加至项目中
                    {
                        project.Controllers.Add(controllerInfo);
                    }
                }
                if (dataFileVersion != 0)//将所有数据转换为当前软件应用的数据版本
                {
                    project = dbFileVersionManager.VersionConverter(dataFileVersion, DBFileVersionManager.CurrentDBFileVersion, project);
                }
                SCA.BusinessLib.ProjectManager.GetInstance.CreateProject(project);
                EventMediator.NotifyColleagues("DisplayTheOpenedProject", null);
            }
        }