public Entity.User LoadUserMapData(System.Data.DataSet dataSet) { //Map the entity data... System.Data.DataTableReader reader = dataSet.Tables[(Int32)UserMap.DataSets.entitydata].CreateDataReader(); Entity.User user = null; //Single record... if (reader.Read()) { List <Entity.SQLEnumeration> roleTypes = EnumerationMapData(dataSet.Tables[(Int32)UserMap.DataSets.enumeration]); user = new User( Int32.Parse(reader[UserMap.Names.id].ToString()), reader[UserMap.Names.sqlSession].ToString(), new UserRole( Int32.Parse(reader[UserMap.Names.roleId].ToString()), reader[UserMap.Names.roleName].ToString(), reader[UserMap.Names.roleDescription].ToString() ), new UserIdentity( reader[UserMap.Names.email].ToString(), reader[UserMap.Names.userGreeting].ToString(), reader[UserMap.Names.userName].ToString(), reader[UserMap.Names.firstName].ToString(), reader[UserMap.Names.lastName].ToString(), reader[UserMap.Names.lastLoginText].ToString(), reader[UserMap.Names.createdText].ToString(), reader[UserMap.Names.editedText].ToString(), DateTime.Parse(reader[UserMap.Names.lastLogin].ToString()), DateTime.Parse(reader[UserMap.Names.created].ToString()), DateTime.Parse(reader[UserMap.Names.edited].ToString()), reader[UserMap.Names.editor].ToString(), Boolean.Parse(reader[UserMap.Names.active].ToString()) ), new UserCredential(), roleTypes ); } if (reader != null) { reader.Dispose(); } return(user); }
public List <Entity.User> LoadListMapData(System.Data.DataTable data) { //Map the entity data... System.Data.DataTableReader reader = data.CreateDataReader(); List <Entity.User> list = new List <User>(data.Rows.Count); //Record set... while (reader.Read()) { list.Add( new User( Int32.Parse(reader[UserMap.Names.id].ToString()), reader[UserMap.Names.sqlSession].ToString(), new UserRole( Int32.Parse(reader[UserMap.Names.roleId].ToString()), reader[UserMap.Names.roleName].ToString(), reader[UserMap.Names.roleDescription].ToString() ), new UserIdentity( reader[UserMap.Names.email].ToString(), reader[UserMap.Names.userGreeting].ToString(), reader[UserMap.Names.userName].ToString(), reader[UserMap.Names.firstName].ToString(), reader[UserMap.Names.lastName].ToString(), reader[UserMap.Names.lastLoginText].ToString(), reader[UserMap.Names.createdText].ToString(), reader[UserMap.Names.editedText].ToString(), DateTime.Parse(reader[UserMap.Names.lastLogin].ToString()), DateTime.Parse(reader[UserMap.Names.created].ToString()), DateTime.Parse(reader[UserMap.Names.edited].ToString()), reader[UserMap.Names.editor].ToString(), Boolean.Parse(reader[UserMap.Names.active].ToString()) ))); } if (reader != null) { reader.Dispose(); } return(list); }
public List <Entity.SQLEnumeration> EnumerationMapData(System.Data.DataTable data) { System.Data.DataTableReader reader = data.CreateDataReader(); List <Entity.SQLEnumeration> list = new List <SQLEnumeration>(data.Rows.Count); while (reader.Read()) { list.Add(new SQLEnumeration( Int16.Parse(reader[UserMap.Names.enumValue].ToString()), reader[UserMap.Names.enumName].ToString(), reader[UserMap.Names.enumDescription].ToString(), Int16.Parse(reader[UserMap.Names.enumSort].ToString()) )); } if (reader != null) { reader.Dispose(); } return(list); }
public Entity.User SaveUserMapData(System.Data.DataTable data) { //Map the entity data... System.Data.DataTableReader reader = data.CreateDataReader(); Entity.User user = null; //Single record... if (reader.Read()) { user = new User( Int32.Parse(reader[UserMap.Names.id].ToString()), reader[UserMap.Names.sqlSession].ToString(), new UserRole( Int32.Parse(reader[UserMap.Names.roleId].ToString()), reader[UserMap.Names.roleName].ToString(), reader[UserMap.Names.roleDescription].ToString() ), new UserIdentity( reader[UserMap.Names.email].ToString(), reader[UserMap.Names.userGreeting].ToString(), reader[UserMap.Names.userName].ToString(), reader[UserMap.Names.firstName].ToString(), reader[UserMap.Names.lastName].ToString(), reader[UserMap.Names.lastLoginText].ToString(), reader[UserMap.Names.createdText].ToString(), reader[UserMap.Names.editedText].ToString(), DateTime.Parse(reader[UserMap.Names.lastLogin].ToString()), DateTime.Parse(reader[UserMap.Names.created].ToString()), DateTime.Parse(reader[UserMap.Names.edited].ToString()), reader[UserMap.Names.editor].ToString(), Boolean.Parse(reader[UserMap.Names.active].ToString()) )); } if (reader != null) { reader.Dispose(); } return(user); }
public Entity.Session <NullT> InitializeMapData(System.Data.DataTable data) { //Map the entity data... System.Data.DataTableReader reader = data.CreateDataReader(); Entity.Session <NullT> init = new Session <NullT>(); //Single record... if (reader.Read()) { init.SessionOk = false; init.ClientMessage = String.Empty; init.ServerMessage = String.Empty; init.SqlKey = reader[UserMap.Names.privateKey].ToString(); init.AppOnline = Boolean.Parse(reader[UserMap.Names.appOnline].ToString()); init.SqlAuthorization = Boolean.Parse(reader[UserMap.Names.sqlAuthorization].ToString()); init.WinAuthorization = Boolean.Parse(reader[UserMap.Names.winAuthorization].ToString()); } if (reader != null) { reader.Dispose(); } return(init); }
/// <summary> /// Retrieve object header, links and properties. /// </summary> /// <param name="header">In/Out header value.</param> /// <param name="links">Array of object links.</param> /// <param name="props">Array of object properties.</param> public void Retrieve( ref HEADER header, out LINK[] links, out PROPERTY[] props ) { #region debug info #if (DEBUG) Debug.Print( "-> ODB.Retrieve( {0}, {1} )", header.ID, header.Type ); #endif #endregion List<PROPERTY> _props = new List<PROPERTY>(); // list to store properties of object List<LINK> _links = new List<LINK>(); // list to store child proxy objects DbDataReader dr = null; DbCommand cmd = null; // init out parameters links = null; props = null; // open connection and start new transaction if required TransactionBegin(); try { // get object header HEADER newHeader = get_header( header.ID ); if( header.Stamp == newHeader.Stamp ) { header = newHeader; // close connection and commit transaction if required TransactionCommit(); return; } #region retrive props from _properties cmd = new SqlCommand( string.Format( "SELECT [Name], [Value] FROM [dbo].[_properties] WHERE [ObjectID] = {0}", header.ID) ); cmd.Connection = m_con; cmd.Transaction = m_trans; dr = cmd.ExecuteReader( CommandBehavior.SingleResult ); try { // read all simple properties of object while( dr.Read() ) { // read properties from row string name = (string) dr["Name"]; object val = dr["Value"]; // convert byte array to memory stream if( val.GetType() == typeof(Byte[] ) ) { val = new PersistentStream((Byte[])val ); } // build PersistentProperty upon recieved name and value and // save property in collection _props.Add( new PROPERTY( name, new ValueBox(val), PROPERTY.STATE.New )); } } finally { // Dispose SqlDataReader dr.Dispose(); } #endregion #region retrive props from _images cmd = new SqlCommand( string.Format( "SELECT [Name] FROM [dbo].[_images] WHERE [ObjectID] = {0}", header.ID) ); cmd.Connection = m_con; cmd.Transaction = m_trans; SqlDataAdapter da = new SqlDataAdapter( (SqlCommand)cmd ); DataTable dt = new DataTable(); // table for object proxy properties da.Fill( dt ); // fill table DataTableReader dtr = new DataTableReader(dt); try { while( dtr.Read() ) { // save data from SqlDataReader because we need non SequentialAccess in datarow string name = (string) dtr["Name"]; // save property in collection _props.Add( new PROPERTY( name, new ValueBox( read_blob( header.ID, name ) ), PROPERTY.STATE.New )); } } finally { dtr.Dispose(); } #endregion #region retrive links cmd = new SqlCommand( string.Format( "SELECT [ID], [ObjectName], [ObjectType], [TimeStamp]\n" + "FROM [dbo].[_objects]\n" + "WHERE [ID] IN (SELECT Child FROM [dbo].[_links] WHERE Parent = {0})", header.ID) ); cmd.Connection = m_con; cmd.Transaction = m_trans; dr = cmd.ExecuteReader( CommandBehavior.SingleResult ); try { while( dr.Read() ) { // save child header _links.Add( new LINK( new HEADER((string) dr["ObjectType"], Convert.ToInt32( dr["ID"] ), Convert.ToDateTime( dr["TimeStamp"] ), (string) dr["ObjectName"] ), LINK.STATE.New)); } } finally { dr.Dispose(); } #endregion props = _props.ToArray(); links = _links.ToArray(); header = newHeader; } catch( Exception ex ) { #region debug info #if (DEBUG) Debug.Print( "[ERROR] @ ODB.Retrive: {0}", ex.ToString() ); #endif #endregion // rollback failed transaction TransactionRollback(); throw; } // close connection and commit transaction if required TransactionCommit(); #region debug info #if (DEBUG) Debug.Print( "<- ODB.Retrieve({0}, {1})", header.ID, header.Type ); #endif #endregion }