public static WIPStationInfo Mapper(WIPStation s) { WIPStationInfo d = Activator.CreateInstance <WIPStationInfo>(); try { var Types = s.GetType(); //获得类型 var Typed = typeof(WIPStationInfo); foreach (PropertyInfo sp in Types.GetProperties()) //获得类型的属性字段 { foreach (PropertyInfo dp in Typed.GetProperties()) { if (dp.Name == sp.Name && dp.CanWrite) //判断属性名是否相同 { dp.SetValue(d, sp.GetValue(s, null), null); //获得s对象属性的值复制给d对象的属性 break; } } } } catch (Exception ex) { throw ex; } return(d); }
private void ilstDevices_SelectedIndexChanged(object sender, EventArgs e) { int selectedPageIndex = -1; if (ilstDevices.SelectedItem != null && (ilstDevices.SelectedItem as ImageListBoxItem).Value is WIPStationInfo) { WIPStationInfo station = (ilstDevices.SelectedItem as ImageListBoxItem).Value as WIPStationInfo; for (int i = 0; i < tcMain.TabPages.Count; i++) { if (tcMain.TabPages[i].Name == station.T133Code) { spccMain.Panel2.Text = $"设备:[{station.WIPStationName}]\t生产情况"; selectedPageIndex = i; break; } } } tcMain.SelectedTabPageIndex = selectedPageIndex; if (selectedPageIndex < 0) { spccMain.Panel2.Text = "生产情况"; } }
private void GetStations( int communityID, long sysLogID) { string strProcedureName = string.Format( "{0}.{1}", className, MethodBase.GetCurrentMethod().Name); WriteLog.Instance.WriteBeginSplitter(strProcedureName); try { int errCode = 0; string errText = ""; List <WIPStation> datas = new List <WIPStation>(); stations.Clear(); IRAPMDMClient.Instance.ufn_GetList_WIPStationsOfAHost( communityID, sysLogID, ref datas, out errCode, out errText); WriteLog.Instance.Write( string.Format("({0}){1}", errCode, errText), strProcedureName); if (errCode != 0) { IRAPMessageBox.Instance.ShowErrorMessage( errText, caption); } else { datas.Sort( new WIPStation_CompareByT133AltCode()); foreach (WIPStation data in datas) { stations.Add(WIPStationInfo.Mapper(data)); } } } finally { WriteLog.Instance.WriteEndSplitter(strProcedureName); } }