public AlarmTemporaryModel GetAlarmTemporaryModel(int did) { IQueryable <AlarmTemporaryModel> source = from record in base.DataContext.AlarmTemporaryInfos join rule in base.DataContext.AlarmRuleInfos on record.RuleDID equals rule.RuleDID join content in base.DataContext.AlarmContentInfos on rule.AlarmTypeDID equals content.DID //join craft in base.DataContext.CraftInfos on record.CraftDID equals craft.CraftDID //join process in base.DataContext.ProcessInfos on record.ProcessDID equals process.ProcessDID join facility in base.DataContext.FacilityInfos on record.FacilityDID equals facility.FacilityDID //join unit in base.DataContext.UnitInfos on record.UnitDID equals unit.UnitDID join alarmLocationImage in base.DataContext.AlarmLocationImageInfos on rule.AlarmLocationImageDID equals alarmLocationImage.DID join solution in base.DataContext.SolutionInfos on rule.SolutionDID equals solution.DID join solutionImage in base.DataContext.SolutionImageInfos on rule.SolutionImageDID equals solutionImage.DID join reason in base.DataContext.AlarmReasonInfos on rule.AlarmTypeDID equals reason.DID join alarmType in base.DataContext.AlarmTypeInfos on rule.AlarmTypeDID equals alarmType.DID where record.AlarmTemporaryDID == did select new AlarmTemporaryModel { AlarmContent = content.Content, DID = record.FacilityDID, AlarmTime = record.AlarmTime, DisposeTime = record.DisposeTime, Duration = record.Duration, FacilityName = facility.MMName, //ProcessName = process.Name, //UnitName = unit.Name, //CraftName = craft.Name, //AlarmCount = (int?)record.AlarmCount, //Address = record.Address, //AlarmLocationImagePath = alarmLocationImage.Path, //AlarmReasonText = reason.Content, //BatteryBarCode = record.BatteryBarCode, //CraftDID = record.CraftDID, //DisposeState = (int?)record.DisposeState, //FacilityDID = record.FacilityDID, //Handler = record.Handler, //ProcessDID = record.ProcessDID, //Remark = record.Remark, //RuleDID = record.RuleDID, //SolutionImagePath = solutionImage.Path, //SolutionText = solution.Content, //UnitDID = record.UnitDID, AlarmTypeName = alarmType.Type }; AlarmTemporaryModel alarmTemporaryModel = source.FirstOrDefault <AlarmTemporaryModel>(); if (alarmTemporaryModel != null) { alarmTemporaryModel.FieldValues = this.GetAlarmRuleFieldValues(alarmTemporaryModel.RuleDID); } return(alarmTemporaryModel); }
private void Page_Loaded(object sender, RoutedEventArgs e) { AlarmTemporaryGetResponse temporaryGetResponse = LocalApi.Execute(new AlarmTemporaryGetRequest() { AlarmTemporaryDID = this.AlarmTemporaryDID }); if (temporaryGetResponse.AlarmTemporary == null) { return; } this.model = temporaryGetResponse.AlarmTemporary; List <FieldRow> fieldRowList1 = new List <FieldRow>(); List <FieldRow> fieldRowList2 = fieldRowList1; FieldRow fieldRow1 = new FieldRow(); fieldRow1.FieldName = "报警编号"; string string1 = this.model.RuleDID.ToString(); fieldRow1.FieldValue = string1; fieldRowList2.Add(fieldRow1); List <FieldRow> fieldRowList3 = fieldRowList1; FieldRow fieldRow2 = new FieldRow(); fieldRow2.FieldName = "报警时间"; string string2 = this.model.AlarmTime.ToString("yyyy-MM-dd HH:mm:ss"); fieldRow2.FieldValue = string2; fieldRowList3.Add(fieldRow2); List <FieldRow> fieldRowList4 = fieldRowList1; FieldRow fieldRow3 = new FieldRow(); fieldRow3.FieldName = "报警内容"; string alarmContent = this.model.AlarmContent; fieldRow3.FieldValue = alarmContent; fieldRowList4.Add(fieldRow3); List <FieldRow> fieldRowList5 = fieldRowList1; FieldRow fieldRow4 = new FieldRow(); fieldRow4.FieldName = "报警部件"; string unitName = this.model.UnitName; fieldRow4.FieldValue = unitName; fieldRowList5.Add(fieldRow4); List <FieldRow> fieldRowList6 = fieldRowList1; FieldRow fieldRow5 = new FieldRow(); fieldRow5.FieldName = "所在工位"; string facilityName = this.model.FacilityName; fieldRow5.FieldValue = facilityName; fieldRowList6.Add(fieldRow5); fieldRowList1.Add(new FieldRow() { FieldName = "报警类型", FieldValue = this.model.AlarmTypeName }); List <FieldRow> fieldRowList7 = fieldRowList1; FieldRow fieldRow6 = new FieldRow(); fieldRow6.FieldName = "异常原因"; string alarmReason = this.model.AlarmReason; fieldRow6.FieldValue = alarmReason; fieldRowList7.Add(fieldRow6); List <FieldRow> fieldRowList8 = fieldRowList1; FieldRow fieldRow7 = new FieldRow(); fieldRow7.FieldName = "解决方案"; string solutionText = this.model.SolutionText; fieldRow7.FieldValue = solutionText; fieldRowList8.Add(fieldRow7); List <FieldRow> fieldRowList9 = fieldRowList1; FieldRow fieldRow8 = new FieldRow(); fieldRow8.FieldName = "报警地址"; string address = this.model.Address; fieldRow8.FieldValue = address; fieldRowList9.Add(fieldRow8); foreach (AlarmFieldValue fieldValue in this.model.FieldValues) { fieldRowList1.Add(new FieldRow() { FieldName = fieldValue.FieldDescription, FieldValue = fieldValue.FieldValue }); } //string urlstring = "C:/" + this.model.AlarmLocationImagePath; string urlstring = System.Environment.CurrentDirectory + this.model.AlarmLocationImagePath; if (System.IO.File.Exists(urlstring)) { this.imgAlarmLocation.Source = new BitmapImage(new Uri(urlstring, UriKind.Absolute)); } else { urlstring = urlstring = System.Environment.CurrentDirectory + "/ErrorPic/Error.jpg"; } this.imgAlarmLocation.Source = new BitmapImage(new Uri(urlstring, UriKind.Absolute)); this.dataGrid.ItemsSource = fieldRowList1; }
public AlarmTemporaryModel GetAlarmTemporaryModel(int did) { Database equipDB = dataProvider.EQUIPDataBase; string sql = string.Format( @"select temp.alarm_temporary_did , temp.rule_did , cr.craft_did , p.process_did , f.facility_did , u.unit_did , temp.alarm_time , temp.dispose_state , temp.dispose_time , temp.handler , temp.duration , temp.address , temp.remark , rule.alarm_content , rule.alarm_reason , sl.content , slimage.path , image.path , cr.craft_name , u.unit_name , p.process_name , f.MMName , almtp.type from alarm_temporary temp join facility_info f on f.facility_did = temp.facility_did join alarm_rule rule on rule.rule_did = temp.rule_did join craft cr on cr.craft_did = rule.craft_did join unit u on u.unit_did = rule.unit_did join alarm_type almtp on almtp.did = rule.alarm_type_did join process p on p.process_did = f.process_did left join alarm_location_image image on image.did = rule.alarm_location_image_did left join solution sl on sl.did = rule.solution_did left join solution_image slimage on slimage.did = rule.solution_image_did where temp.alarm_temporary_did = {0};" , did); DataSet ds = equipDB.ExecuteDataSet(CommandType.Text, sql); DataTable tb = ds.Tables[0]; if (tb != null && tb.Rows.Count > 0) { AlarmTemporaryModel model = new AlarmTemporaryModel(); model.DID = int.Parse(tb.Rows[0][0].ToString()); model.RuleDID = tb.Rows[0][1].ToString(); model.CraftDID = int.Parse(tb.Rows[0][2].ToString()); model.ProcessDID = int.Parse(tb.Rows[0][3].ToString()); model.FacilityDID = int.Parse(tb.Rows[0][4].ToString()); model.UnitDID = int.Parse(tb.Rows[0][5].ToString()); model.AlarmTime = DateTime.Parse(tb.Rows[0][6].ToString()); if (tb.Rows[0][7].ToString() != "") { model.DisposeState = 0; } int.Parse(tb.Rows[0][7].ToString()); if (tb.Rows[0][8].ToString() != "") { model.DisposeTime = DateTime.Parse(tb.Rows[0][8].ToString()); } model.Handler = tb.Rows[0][9].ToString(); if (tb.Rows[0][10].ToString() != "") { model.Duration = int.Parse(tb.Rows[0][10].ToString()); } model.Address = tb.Rows[0][11].ToString(); model.Remark = tb.Rows[0][12].ToString(); model.AlarmContent = tb.Rows[0][13].ToString(); model.AlarmReason = tb.Rows[0][14].ToString(); model.SolutionText = tb.Rows[0][15].ToString(); model.SolutionImagePath = tb.Rows[0][16].ToString(); model.AlarmLocationImagePath = tb.Rows[0][17].ToString(); model.CraftName = tb.Rows[0][18].ToString(); model.UnitName = tb.Rows[0][19].ToString(); model.ProcessName = tb.Rows[0][20].ToString(); model.FacilityName = tb.Rows[0][21].ToString(); model.AlarmTypeName = tb.Rows[0][22].ToString(); model.FieldValues = this.GetAlarmRuleFieldValues(model.RuleDID); return(model); } else { throw new Exception("执行GetAlarmTemporaryModel未查询到数据"); } }