private void BuildMemberAccess(TypeNode type, SequenceAccessor acc, bool deep, bool isStatic, Hashtable visited){ TypeAlias ta = type as TypeAlias; if (ta != null) type = ta.AliasedType; if (type.BaseType != null && type.BaseType != SystemTypes.Object){ this.BuildMemberAccess(type.BaseType, acc, deep, isStatic, visited); } MemberList members = type.Members; for( int i = 0, n = members.Count; i < n; i++ ){ Member m = members[i]; if (m == null) continue; if (!(m is Property || m is Field)) continue; if (!m.IsPublic) continue; if (m.IsStatic != isStatic) continue; // don't add additional references to overridden members if (m.OverridesBaseClassMember) continue; // hidden members are not visible, remove hidden ones if (m.HidesBaseClassMember){ for( int j = acc.Accessors.Count - 1; j >= 0; j-- ){ MemberAccessor mac = (MemberAccessor)acc.Accessors[j]; if (mac.Member.Name.Name == m.Name.Name){ acc.Accessors.RemoveAt(j); } } } Property p = m as Property; if (p != null && p.Parameters != null && p.Parameters.Count > 0) continue; MemberAccessor ma = new MemberAccessor(m); TypeNode mtype = this.typeSystem.GetMemberType(ma.Member); ma.Type = this.typeSystem.GetRootType(mtype, this.TypeViewer); if (ma.Type != null && !ma.Type.IsPrimitive){ if (deep || this.IsTransparent(ma.Member)){ ma.Next = this.BuildAccessGraph(ma.Type, deep, isStatic, visited); } } acc.Accessors.Add(ma); } }
private Accessor BuildAccessGraph(TypeNode type, bool deep, bool isStatic, Hashtable visited){ Accessor acc = (Accessor) visited[type]; if (acc != null) return acc; TypeUnion tu = type as TypeUnion; if (tu != null){ SwitchAccessor sw = new SwitchAccessor(); visited[type] = sw; sw.Type = tu; for( int i = 0, n = tu.Types.Count; i < n; i++ ){ TypeNode tn = this.typeSystem.GetRootType(tu.Types[i], this.TypeViewer); if (tn == null) continue; sw.Accessors.Add(i, this.BuildAccessGraph(tn, deep, isStatic, visited)); } return sw; } // queries don't see through intersection types, // assume intersection type is a derived class w/ all private members TypeIntersection ti = type as TypeIntersection; if (ti != null){ return null; } // examine members SequenceAccessor accessor = new SequenceAccessor(); visited[type] = accessor; this.BuildMemberAccess(type, accessor, deep, isStatic, visited); return accessor; }
public virtual void BuildAxisClosureSequence(Expression source, AxisBuildState state, SequenceAccessor sqa, Block block, BlockScope scope) { if (!this.IsLocal(source)) { Expression loc = this.NewClosureLocal(source.Type, scope); block.Statements.Add(new AssignmentStatement(loc, source)); source = loc; } foreach( Accessor acc in sqa.Accessors ) { block.Statements.Add(this.BuildAxisClosureBlock(source, state, acc, scope)); } }
public string GetNewID() { return(SequenceAccessor.GetNewId()); }
public void Import() { OraMetaDataFactroy _of = new OraMetaDataFactroy(); IDDict = new Dictionary <decimal, decimal>(); //MD_INPUTVIEW 命名空间转换及ID转换 DataTable TB_IV = ImportSourceDataSet.Tables["MD_INPUTVIEW"]; foreach (DataRow _dr in TB_IV.Rows) { ModelName = _dr["IV_NAME"].ToString(); _dr["NAMESPACE"] = CurrentNs.NameSpace; decimal _newid = decimal.Parse(SequenceAccessor.GetNewId()); decimal _oldid = (decimal)_dr["IV_ID"]; _dr["IV_ID"] = _newid; IDDict.Add(_oldid, _newid); } //其它各表的ID值转换 DataTable TB_INPUTGROUP = ImportSourceDataSet.Tables["MD_INPUTGROUP"]; foreach (DataRow _dr in TB_INPUTGROUP.Rows) { decimal _newid = decimal.Parse(SequenceAccessor.GetNewId()); decimal _oldid = (decimal)_dr["IVG_ID"]; _dr["IVG_ID"] = _newid; IDDict.Add(_oldid, _newid); _dr["IV_ID"] = IDDict[(decimal)_dr["IV_ID"]]; } DataTable TB_INPUTVIEWCOLUMN = ImportSourceDataSet.Tables["MD_INPUTVIEWCOLUMN"]; foreach (DataRow _dr in TB_INPUTVIEWCOLUMN.Rows) { decimal _newid = decimal.Parse(SequenceAccessor.GetNewId()); decimal _oldid = (decimal)_dr["IVC_ID"]; _dr["IVC_ID"] = _newid; IDDict.Add(_oldid, _newid); _dr["IV_ID"] = IDDict[(decimal)_dr["IV_ID"]]; decimal _ivgid = (decimal)_dr["IVG_ID"]; if (_ivgid != 0) { _dr["IVG_ID"] = IDDict[(decimal)_dr["IVG_ID"]]; } } DataTable TB_INPUTTABLE = ImportSourceDataSet.Tables["MD_INPUTTABLE"]; foreach (DataRow _dr in TB_INPUTTABLE.Rows) { decimal _newid = decimal.Parse(SequenceAccessor.GetNewId()); decimal _oldid = (decimal)_dr["ID"]; _dr["ID"] = _newid; IDDict.Add(_oldid, _newid); _dr["IV_ID"] = IDDict[(decimal)_dr["IV_ID"]]; } DataTable TB_INPUTVIEWCHILD = ImportSourceDataSet.Tables["MD_INPUTVIEWCHILD"]; foreach (DataRow _dr in TB_INPUTVIEWCHILD.Rows) { decimal _newid = decimal.Parse(SequenceAccessor.GetNewId()); decimal _oldid = (decimal)_dr["ID"]; _dr["ID"] = _newid; IDDict.Add(_oldid, _newid); _dr["IV_ID"] = IDDict[(decimal)_dr["IV_ID"]]; } DataTable TB_INPUTTABLECOLUMN = ImportSourceDataSet.Tables["MD_INPUTTABLECOLUMN"]; foreach (DataRow _dr in TB_INPUTTABLECOLUMN.Rows) { decimal _newid = decimal.Parse(SequenceAccessor.GetNewId()); decimal _oldid = (decimal)_dr["ID"]; _dr["ID"] = _newid; IDDict.Add(_oldid, _newid); _dr["IVT_ID"] = IDDict[(decimal)_dr["IVT_ID"]]; } //写入数据库 using (SqlConnection cn = SqlHelper.OpenConnection()) { SqlTransaction _txn = cn.BeginTransaction(); try { SqlCommand _cmd = new SqlCommand("select * from md_inputview ", cn); SqlDataAdapter _oda = new SqlDataAdapter(_cmd); SqlCommandBuilder builder = new SqlCommandBuilder(_oda); _oda.Update(ResetState(TB_IV)); _cmd = new SqlCommand("select * from md_inputgroup ", cn); _oda = new SqlDataAdapter(_cmd); builder = new SqlCommandBuilder(_oda); _oda.Update(ResetState(TB_INPUTGROUP)); _cmd = new SqlCommand("select * from md_inputtable ", cn); _oda = new SqlDataAdapter(_cmd); builder = new SqlCommandBuilder(_oda); _oda.Update(ResetState(TB_INPUTTABLE)); _cmd = new SqlCommand("select * from md_inputtablecolumn", cn); _oda = new SqlDataAdapter(_cmd); builder = new SqlCommandBuilder(_oda); _oda.Update(ResetState(TB_INPUTTABLECOLUMN)); _cmd = new SqlCommand("select * from md_inputviewchild ", cn); _oda = new SqlDataAdapter(_cmd); builder = new SqlCommandBuilder(_oda); _oda.Update(ResetState(TB_INPUTVIEWCHILD)); _cmd = new SqlCommand("select * from md_inputviewcolumn ", cn); _oda = new SqlDataAdapter(_cmd); builder = new SqlCommandBuilder(_oda); _oda.Update(ResetState(TB_INPUTVIEWCOLUMN)); _txn.Commit(); } catch (Exception e) { _txn.Rollback(); LogWriter.WriteSystemLog(string.Format("在导入录入模型时出错,错误信息:{0}", e.Message), "ERROR"); throw e; } } }