private void LoadFile() { if (!string.IsNullOrWhiteSpace(txtFileName.Text)) { TestPlanVM MTSM = new ViewModelLocator().CurrentTestPlanVm; MTSM.DisplayName = strFile; byte[] statefile = System.IO.File.ReadAllBytes(txtFileName.Text); if (statefile != null && statefile.Length > 0) { TestPlan testPlan = new TestPlan(); object obj = Interface.DeSerializerStateModel(statefile, testPlan); testPlan = obj as TestPlan; if (testPlan != null) { MTSM.TestPlan = testPlan; } } else { MTSM.TestPlan = new TestPlan(); } MTSM.DisplayName = strFile; MTSM.ApplyTestPlan(); (new ViewModelLocator()).MainWindow.StatusInfo.OpenProject = strFile; MTSM.DisplayName = strFile; CloseTestResultPanel(); } else { DXMessageBox.Show("请选择一个方案,执行加载程序!", "加载程序", MessageBoxButton.OK, MessageBoxImage.Error); return; } }
//连接数据库 private void LoadFileFromID(string id) { DataSet ds = null; if (DataUtils.StaticInfo.MesMode.ToLower() == "true") { ds = DataUtils.DB.GetDataSetFromSQL(string.Format("SELECT StateData,Material FROM SYS_TEST_PLAN WHERE FILEID='{0}'", id)); } else { ds = DataUtils.DB.GetDataSetFromSQL(string.Format("SELECT StateData, FileName as Material FROM ATE_TEST_FILE WHERE FILEID='{0}'", id)); } if (ds.Tables[0].Rows.Count > 0) { TestPlanVM MTSM = new ViewModelLocator().CurrentTestPlanVm; if (ds.Tables[0].Rows[0]["StateData"] != System.DBNull.Value) { byte[] data = (byte[])ds.Tables[0].Rows[0]["StateData"]; // TestPlanVM testPlan = new TestPlanVM(); TestPlan testPlan = new TestPlan(); object obj = Interface.DeSerializerStateModel(data, testPlan); testPlan = obj as TestPlan; if (testPlan != null) { MTSM.TestPlan = testPlan; } } else { MTSM.TestPlan = new TestPlan(); } MTSM.DisplayName = ds.Tables[0].Rows[0]["Material"].ToString(); MTSM.ApplyTestPlan(); (new ViewModelLocator()).MainWindow.StatusInfo.OpenProject = ds.Tables[0].Rows[0]["Material"].ToString(); (new ViewModelLocator()).MainWindow.StatusInfo.Material = MTSM.DisplayName; SaveStateFileToXml(id); foreach (StateFileModel sfModel in fileVM.CurrentFileList) { if (sfModel.Name != MTSM.DisplayName) { sfModel.IsLoad = false; } else { sfModel.IsLoad = true; } } } }
/// <summary> /// 没有用到 /// </summary> /// <param name="SN"></param> /// <returns></returns> private bool GetSNData(string SN) { routeLine.GetRouteBySN(SN); //亨鑫使用 string token = (new ViewModelLocator()).MainWindow.StatusInfo.Token; string resValue = ServiceInterface.DataService.CheckINBYSN(token, SN); if (resValue.StartsWith("ER")) { DXMessageBox.Show("序号:[" + SN + "]处理异常!异常消息:[" + resValue + "]"); return(false); } if (false) { TestPlanVM MTSM = new ViewModelLocator().CurrentTestPlanVm; byte[] StateFile = Interface.SerializerStateModel(MTSM.TestPlan); string StateFileHasCode = Interface.GetMD5HashFromByte(StateFile); bool CheckStatFileBySn = ServiceInterface.DataService.CheckStatFileBySn(token, SN, StateFileHasCode); if (!CheckStatFileBySn) { return(true); } byte[] bStatFile = ServiceInterface.DataService.DownLoadStatFile(token, SN); if (bStatFile != null) { TestPlanVM testPlan = Interface.DeSerializerStateModel(bStatFile, testPlan) as TestPlanVM; if (testPlan != null) { MTSM.TestPlan = testPlan.TestPlan; } } else { MTSM.TestPlan = new TestPlan(); } MTSM.ApplyTestPlan(); vm = MTSM; vm.UpdateData = new Action <int>(UpdateTestData); } return(true); }
private bool GetStatusFile(string material, string process) { bool IsLoad = false; DataSet ds = DataUtils.DB.GetDataSetFromSQL(string.Format("SELECT StateData,Material FROM SYS_TEST_PLAN WHERE Material='{0}' and Process='{1}'", material, process)); if (ds.Tables[0].Rows.Count > 0) { TestPlanVM MTSM = new ViewModelLocator().CurrentTestPlanVm; if (ds.Tables[0].Rows[0]["StateData"] != System.DBNull.Value) { byte[] data = (byte[])ds.Tables[0].Rows[0]["StateData"]; TestPlan testPlan = new TestPlan(); object obj = Interface.DeSerializerStateModel(data, testPlan); testPlan = obj as TestPlan; testPlan.SN = vm.SN; if (testPlan != null) { MTSM.TestPlan = testPlan; } } else { MTSM.TestPlan = new TestPlan(); } MTSM.DisplayName = ds.Tables[0].Rows[0]["Material"].ToString(); MTSM.ApplyTestPlan(); (new ViewModelLocator()).MainWindow.StatusInfo.OpenProject = ds.Tables[0].Rows[0]["Material"].ToString(); (new ViewModelLocator()).MainWindow.StatusInfo.Material = MTSM.DisplayName; foreach (var item in vm.listenerlist) { item.TestPlan = MTSM.TestPlan; } IsLoad = true; } else { TestPlanVM MTSM = new ViewModelLocator().CurrentTestPlanVm; MTSM.TestPlan = new TestPlan(); MTSM.DisplayName = null; (new ViewModelLocator()).MainWindow.StatusInfo.OpenProject = null; (new ViewModelLocator()).MainWindow.StatusInfo.Material = MTSM.DisplayName; } return(IsLoad); }
private bool GetStatusFile(string id) { IsLoad = false; DataSet ds = null; if (DataUtils.StaticInfo.MesMode.ToLower() == "true") { ds = DataUtils.DB.GetDataSetFromSQL(string.Format("SELECT StateData,Material FROM SYS_TEST_PLAN WHERE FILEID='{0}'", id)); } else { ds = DataUtils.DB.GetDataSetFromSQL(string.Format("SELECT StateData, FileName as Material FROM ATE_TEST_FILE WHERE FILEID='{0}'", id)); } if (ds.Tables[0].Rows.Count > 0) { TestPlanVM MTSM = new ViewModelLocator().CurrentTestPlanVm; if (ds.Tables[0].Rows[0]["StateData"] != System.DBNull.Value) { byte[] data = (byte[])ds.Tables[0].Rows[0]["StateData"]; TestPlan testPlan = new TestPlan(); object obj = Interface.DeSerializerStateModel(data, testPlan); testPlan = obj as TestPlan; if (testPlan != null) { MTSM.TestPlan = testPlan; IsLoad = true; } } else { MTSM.TestPlan = new TestPlan(); } MTSM.ApplyTestPlan(); MTSM.DisplayName = ds.Tables[0].Rows[0]["Material"].ToString(); (new ViewModelLocator()).MainWindow.StatusInfo.OpenProject = ds.Tables[0].Rows[0]["Material"].ToString(); (new ViewModelLocator()).MainWindow.StatusInfo.Material = MTSM.DisplayName; } return(IsLoad); }