public ControllerModel OrganizeControllerInfoFromSpecifiedDBFileVersion(IDBFileVersionService dbFileVersionService, ControllerModel controller)
        {
            ControllerModel  controllerInfo = controller;
            List <LoopModel> lstLoopInfo    = dbFileVersionService.GetLoopsByController(controller);
            StringBuilder    sbQuerySQL     = new StringBuilder();

            //(1)回路及器件
            foreach (var l in lstLoopInfo)//回路信息
            {
                LoopModel loop = l;
                dbFileVersionService.GetDevicesByLoopForControllerType8003(ref loop);//为loop赋予“器件信息”
                loop.Controller = controllerInfo;
                controllerInfo.Loops.Add(loop);
            }
            //(2)标准组态
            List <LinkageConfigStandard> lstStandard = dbFileVersionService.GetStandardLinkageConfig(controller);

            foreach (var l in lstStandard)
            {
                LinkageConfigStandard standardConfig = l;
                standardConfig.Controller = controllerInfo;
                controllerInfo.StandardConfig.Add(standardConfig);
            }

            return(controllerInfo);
        }
Example #2
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 #3
0
        public static IDeviceDBServiceTest GetDeviceDBContext(ControllerType type, IDBFileVersionService dbFileVersionService)
        {
            switch (type)
            {
            case ControllerType.NT8036:
                // return (IDeviceDBService<IDevice>) new Device8036DBService(databaseService);
                return(new Device8036DBServiceTest(dbFileVersionService));

            case ControllerType.NT8007:
                return(new Device8007DBServiceTest(dbFileVersionService));

            case ControllerType.NT8001:
                return(new Device8001DBService(dbFileVersionService));

            case ControllerType.FT8000:
                return(new Device8000DBService(dbFileVersionService));

            case ControllerType.FT8003:
                return(new Device8003DBService(dbFileVersionService));

            case ControllerType.NT8021:
                return(new Device8021DBService(dbFileVersionService));

            case ControllerType.NT8053:
                return(new Device8053DBService(dbFileVersionService));
            }
            return(null);
        }
Example #4
0
        public ControllerModel OrganizeControllerInfoFromSpecifiedDBFileVersion(IDBFileVersionService dbFileVersionService, ControllerModel controller)
        {
            ControllerModel  controllerInfo = controller;
            List <LoopModel> lstLoopInfo    = dbFileVersionService.GetLoopsByController(controller);
            StringBuilder    sbQuerySQL     = new StringBuilder();

            //set sdpkey=xianggh,xianggh= (Round((xianggh/756)+.4999999)-1),panhao=IIF(Round(((xianggh/63))+.4999999)>12,Round(((xianggh/63))+.4999999)-12,Round(((xianggh/63))+.4999999)),jianhao=IIF((xianggh Mod 63)=0,63,xianggh Mod 63)

            //(1)回路及器件
            foreach (var l in lstLoopInfo)//回路信息
            {
                LoopModel loop = l;
                dbFileVersionService.GetDevicesByLoopForControllerType8000(ref loop);//为loop赋予“器件信息”
                loop.Controller = controllerInfo;
                controllerInfo.Loops.Add(loop);
            }
            //(2)标准组态
            List <LinkageConfigStandard> lstStandard = dbFileVersionService.GetStandardLinkageConfig(controller);

            foreach (var l in lstStandard)
            {
                LinkageConfigStandard standardConfig = l;
                standardConfig.Controller = controllerInfo;
                controllerInfo.StandardConfig.Add(standardConfig);
            }

            return(controllerInfo);
        }
        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);
        }
Example #6
0
 /// <summary>
 /// 创建Project
 /// </summary>
 /// <param name="project"></param>
 /// <returns></returns>
 public Model.ProjectModel CreateProject(ProjectModel project, IProjectService projectService, IFileService fileService)
 {
     if (projectService.CreateProject(project, fileService))
     {
         Project = project; //将对象信息赋给当前属性
         ILogRecorder logger = null;
         SCA.BusinessLogic.DBFileVersionManager dbFileVersionManager = new SCA.BusinessLogic.DBFileVersionManager(Project.SavePath, logger, fileService);
         _dbFileVersionService = dbFileVersionManager.GetDBFileVersionServiceByVersionID(SCA.BusinessLogic.DBFileVersionManager.CurrentDBFileVersion);
         InitializeDefaultSetting();
     }
     //  IsDirty = true;
     return(Project);
 }
Example #7
0
        public void OpenProject(string strPath)
        {
            ILogRecorder logger = null;


            //_databaseService = new SCA.DatabaseAccess.SQLiteDatabaseAccess(strPath, logger, _fileService);

            SCA.BusinessLogic.DBFileVersionManager dbFileVersionManager = new SCA.BusinessLogic.DBFileVersionManager(strPath, logger, _fileService);
            _dbFileVersionService = dbFileVersionManager.GetDBFileVersionServiceByVersionID(SCA.BusinessLogic.DBFileVersionManager.CurrentDBFileVersion);
            InitializeDefaultSetting();
            IDeviceDBServiceTest   deviceDBService;
            ProjectModel           project        = _projectDBService.GetProject(1);
            List <ControllerModel> lstControllers = _controllerDBService.GetControllersByProject(project);

            foreach (ControllerModel c in lstControllers)
            {
                List <LoopModel> lstLoops = _loopDBService.GetLoopsByController(c);
                foreach (LoopModel l in lstLoops)
                {
                    deviceDBService = SCA.DatabaseAccess.DBContext.DeviceManagerDBServiceTest.GetDeviceDBContext(c.Type, _dbFileVersionService);
                    c.Loops.Add(deviceDBService.GetDevicesByLoop(l));
                }
                List <LinkageConfigStandard> lstStandards = _linkageConfigStandardDBService.GetStandardLinkageConfigInfoByController(c);
                foreach (var s in lstStandards)
                {
                    c.StandardConfig.Add(s);
                }
                List <LinkageConfigMixed> lstMixed = _linkageConfigMixedDBService.GetMixedLinkageConfigInfo(c);
                foreach (var s in lstMixed)
                {
                    c.MixedConfig.Add(s);
                }
                List <LinkageConfigGeneral> lstGeneral = _linkageConfigGeneralDBService.GetGeneralLinkageConfigInfo(c);
                foreach (var s in lstGeneral)
                {
                    c.GeneralConfig.Add(s);
                }
                List <ManualControlBoard> lstMCB = _manualControlBoardDBService.GetManualControlBoardInfo(c);
                foreach (var s in lstMCB)
                {
                    c.ControlBoard.Add(s);
                }
                project.Controllers.Add(c);
            }
            //private IManualControlBoardDBService _manualControlBoardDBService;
            project.SavePath = strPath;
            this.Project     = project;
            SetMaxIDWithMemoryData();
            RecentFiles.Add(Project.SavePath);
            SaveRecentFiles();
        }
Example #8
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);
 }
        public ControllerModel OrganizeControllerInfoFromSpecifiedDBFileVersion(IDBFileVersionService dbFileVersionService, ControllerModel controller)
        {
            ControllerModel  controllerInfo = controller;
            List <LoopModel> lstLoopInfo    = dbFileVersionService.GetLoopsByController(controller);
            StringBuilder    sbQuerySQL     = new StringBuilder();

            //(1)回路及器件
            foreach (var l in lstLoopInfo)//回路信息
            {
                LoopModel loop = l;
                dbFileVersionService.GetDevicesByLoopForControllerType8021(ref loop);//为loop赋予“器件信息”
                loop.Controller = controllerInfo;
                controllerInfo.Loops.Add(loop);
            }

            return(controllerInfo);
        }
Example #10
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);
 }
Example #11
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);
 }
 public LinkageConfigGeneralDBService(IDBFileVersionService dbFileVersionService)
 {
     _dbFileVersionService = dbFileVersionService;
 }
Example #13
0
 public Device8003DBService(IDBFileVersionService dbFileVersionService)
 {
     _dbFileVersionService = dbFileVersionService;
 }
Example #14
0
 public DeviceTypeDBService(IDBFileVersionService dbFileVersionService)
 {
     _dbFileVersionService = dbFileVersionService;
 }
Example #15
0
 public ProjectDBService(IDBFileVersionService dbFileVersionService)
 {
     _dbFileVersionService = dbFileVersionService;
 }
Example #16
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);
            }
        }
Example #17
0
 public ControllerDBService(IDBFileVersionService dbFileVersionService)
 {
     _dbFileVersionService = dbFileVersionService;
 }
Example #18
0
 public Model.ControllerModel OrganizeControllerInfoFromSpecifiedDBFileVersion(IDBFileVersionService dbFileVersionService, Model.ControllerModel controller)
 {
     throw new NotImplementedException();
 }
Example #19
0
 public LoopDBService(IDBFileVersionService dbFileVersionService)
 {
     _dbFileVersionService = dbFileVersionService;
 }
 public ManualControlBoardDBService(IDBFileVersionService dbFileVersionService)
 {
     _dbFileVersionService = dbFileVersionService;
 }
 public LinkageConfigMixedDBService(IDBFileVersionService dbFileVersionService)
 {
     _dbFileVersionService = dbFileVersionService;
 }
Example #22
0
 public LinkageConfigStandardDBService(IDBFileVersionService dbFileVersionService)
 {
     _dbFileVersionService = dbFileVersionService;
 }
Example #23
0
 public Device8036DBServiceTest(IDBFileVersionService dbFileVersionService)
 {
     _dbFileVersionService = dbFileVersionService;
 }