private void ConfirmButton_Click(object sender, RoutedEventArgs e) { SCA.Model.ProjectModel project = new Model.ProjectModel(); project.Name = this.ProjectNameInputTextBox.Text; project.SavePath = SaveFilePathInputTextBox.Text; string strImportedFilePath = ImportFilePathInputTextBox.Text; //string strProjectFileSavePath = SaveFilePathInputTextBox.Text; //string strProjectName = ProjectNameInputTextBox.Text; // project.SavePath = this.FilePathInputTextBox.Text; //~~~~~~~~ IFileService _fileService = new FileService(); IDatabaseService _databaseService; ILogRecorder _logRecorder; _databaseService = new MSAccessDatabaseAccess(strImportedFilePath, null, _fileService); IOldVersionSoftwareDBService oldVersionService = new OldVersionSoftware8036DBService(_databaseService); IControllerOperation controllerOperation = null; string[] strFileInfo = oldVersionService.GetFileVersionAndControllerType(); ControllerModel controllerInfo = null; if (strFileInfo.Length > 0) { switch (strFileInfo[0]) { case "8036": controllerOperation = new ControllerOperation8036(_databaseService); break; } if (controllerOperation != null) { controllerInfo = controllerOperation.OrganizeControllerInfoFromOldVersionSoftwareDataFile(oldVersionService); } //strFileInfo[1]; } //~~~~~~~~~ project.Controllers.Add(controllerInfo); SCA.BusinessLib.ProjectManager.GetInstance.CreateProject(project); RaiseEvent(new RoutedEventArgs(ConfirmButtonClickEvent)); }
public void ConvertOldVersionSoftwareDataFileToCurrentModel8036() { _databaseService = new MSAccessDatabaseAccess(@"C:\Users\Administrator\Desktop\foo\8036.mdb", _logRecorder, _fileService); IOldVersionSoftwareDBService oldVersionService = new OldVersionSoftware8036DBService(_databaseService); IControllerOperation controllerOperation = null; string[] strFileInfo = oldVersionService.GetFileVersionAndControllerType(); ControllerModel controllerInfo = null; if (strFileInfo.Length > 0) { switch (strFileInfo[0]) { case "8036": controllerOperation = new ControllerOperation8036(_databaseService); break; } if (controllerOperation != null) { controllerInfo = controllerOperation.OrganizeControllerInfoFromOldVersionSoftwareDataFile(oldVersionService); } //strFileInfo[1]; } Assert.That(controllerInfo.Type, Is.EqualTo(ControllerType.NT8036), "控制器类型不正确"); Assert.That(controllerInfo.Loops.Count, Is.EqualTo(2), "回路数量不正确"); Assert.That(controllerInfo.Loops[0].Code, Is.EqualTo("00101"), "回路名称不正确"); Assert.That(controllerInfo.Loops[0].DeviceAmount, Is.EqualTo(46), "01回路数量不正确"); Assert.That(controllerInfo.Loops[0].GetDevices <Model.DeviceInfo8036>()[0].Code, Is.EqualTo("00101001"), "器件编码不正确"); Assert.That(controllerInfo.Loops[1].Code, Is.EqualTo("00102"), "回路名称不正确"); Assert.That(controllerInfo.StandardConfig.Count, Is.EqualTo(1), "标准组态数量为1"); Assert.That(controllerInfo.StandardConfig[0].Code, Is.EqualTo("0001"), "标准组态编号为0001"); Assert.That(controllerInfo.StandardConfig[0].DeviceNo4, Is.EqualTo("00001009"), "编号4的编号为00001009"); Assert.That(controllerInfo.StandardConfig[0].LinkageNo3, Is.EqualTo("0003"), "联动组3的编号为0003"); }
public HierarchyViewModel() { IProjectManager projManager = ProjectManager.GetInstance; IFileService _fileService = new FileService(); IDatabaseService _databaseService = new MSAccessDatabaseAccess(@"C:\Users\Administrator\Desktop\foo\8036.mdb", null, _fileService); IOldVersionSoftwareDBService oldVersionService = new OldVersionSoftware8036DBService(_databaseService); IControllerOperation controllerOperation = null; string[] strFileInfo = oldVersionService.GetFileVersionAndControllerType(); ControllerModel controllerInfo = null; if (strFileInfo.Length > 0) { switch (strFileInfo[0]) { case "8036": controllerOperation = new ControllerOperation8036(_databaseService); break; } if (controllerOperation != null) { controllerInfo = controllerOperation.OrganizeControllerInfoFromOldVersionSoftwareDataFile(oldVersionService); } //strFileInfo[1]; } ProjectModel proj = new ProjectModel() { ID = 1, Name = "尼特智能" }; proj.Controllers.Add(controllerInfo); _databaseService = new MSAccessDatabaseAccess(@"E:\2016\6 软件优化升级\4 实际工程数据\工程数据111\连城心怡都城_文件版本5.mdb", null, _fileService); oldVersionService = new OldVersionSoftware8001DBService(_databaseService); strFileInfo = oldVersionService.GetFileVersionAndControllerType(); controllerInfo = null; if (strFileInfo.Length > 0) { switch (strFileInfo[0]) { case "8001": controllerOperation = new ControllerOperation8001(null); break; } if (controllerOperation != null) { controllerInfo = controllerOperation.OrganizeControllerInfoFromOldVersionSoftwareDataFile(oldVersionService); } //strFileInfo[1]; } proj.Controllers.Add(controllerInfo); projManager.CreateProject(proj); List <ProjectModel> lstProjects = new List <ProjectModel>(); lstProjects.Add(proj); Initialize(lstProjects, null); }