private EventStream DeserializeEvents(Guid id, SqlDataReader result) { var lastVersion = 0; var snapshotVersion = 0; var eventTypeIdColumnId = result.GetOrdinal("EventTypeId"); var eventDataColumnId = result.GetOrdinal("EventData"); var versionColumnId = result.GetOrdinal("Version"); var snapshotVersionColumnId = result.GetOrdinal("SnapshotVersion"); var events = new List<object>(); while (result.Read()) { var eventTypeId = result.GetSqlGuid(eventTypeIdColumnId).Value; lastVersion = result.GetSqlInt32(versionColumnId).Value; snapshotVersion = result.GetSqlInt32(snapshotVersionColumnId).Value; events.Add(this.serializationMethod.Deserialize(new XmlSerializedData(eventTypeId, result.GetSqlXml(eventDataColumnId).CreateReader()))); } return new EventStream(id, lastVersion, snapshotVersion, events); }
/// <summary> /// [To be supplied.] /// </summary> public void Refresh() { internalRecords = new System.Collections.ArrayList(); bool alreadyOpened = false; Params.spS_JobPartType_Display Param = new Params.spS_JobPartType_Display(true); Param.CommandTimeOut = this.selectCollectionCommandTimeOut; switch (this.lastKnownConnectionType) { case Bob.DataClasses.ConnectionType.ConnectionString: Param.SetUpConnection(this.connectionString); break; case Bob.DataClasses.ConnectionType.SqlConnection: Param.SetUpConnection(this.sqlConnection); alreadyOpened = (this.sqlConnection.State == System.Data.ConnectionState.Open); break; case Bob.DataClasses.ConnectionType.SqlTransaction: Param.SetUpConnection(this.sqlTransaction); break; } System.Data.SqlClient.SqlDataReader sqlDataReader = null; SPs.spS_JobPartType_Display Sp = new SPs.spS_JobPartType_Display(false); if (Sp.Execute(ref Param, out sqlDataReader)) { while (sqlDataReader.Read()) { JobPartType_Record record = null; switch (this.lastKnownConnectionType) { case Bob.DataClasses.ConnectionType.ConnectionString: record = new JobPartType_Record(this.connectionString, sqlDataReader.GetSqlInt32(SPs.spS_JobPartType_Display.Resultset1.Fields.Column_ID1.ColumnIndex)); break; case Bob.DataClasses.ConnectionType.SqlConnection: record = new JobPartType_Record(this.sqlConnection, sqlDataReader.GetSqlInt32(SPs.spS_JobPartType_Display.Resultset1.Fields.Column_ID1.ColumnIndex)); break; case Bob.DataClasses.ConnectionType.SqlTransaction: record = new JobPartType_Record(this.sqlTransaction, sqlDataReader.GetSqlInt32(SPs.spS_JobPartType_Display.Resultset1.Fields.Column_ID1.ColumnIndex)); break; } record.UpdateCommandTimeOut = this.updateCommandTimeOut; record.SelectCommandTimeOut = this.selectCommandTimeOut; if (sqlDataReader.GetFieldType(SPs.spS_JobPartType_Display.Resultset1.Fields.Column_Display.ColumnIndex) == typeof(string)) { record.displayName = sqlDataReader.GetString(SPs.spS_JobPartType_Display.Resultset1.Fields.Column_Display.ColumnIndex); } else { record.displayName = sqlDataReader.GetValue(SPs.spS_JobPartType_Display.Resultset1.Fields.Column_Display.ColumnIndex).ToString(); } internalRecords.Add(record); } if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } CloseConnection(Sp.Connection, alreadyOpened); this.recordsAreLoaded = true; } else { if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } CloseConnection(Sp.Connection, alreadyOpened); this.recordsAreLoaded = false; throw new Bob.DataClasses.CustomException(Param, "Bob.BusinessComponents.JobPartType_Collection", "Refresh"); } }
/// <summary> /// [To be supplied.] /// </summary> /// <returns>[To be supplied.]</returns> public bool Refresh() { this.displayName = null; this.col_CompanyNameWasUpdated = false; this.col_CompanyNameWasSet = false; this.col_CompanyName = System.Data.SqlTypes.SqlString.Null; this.col_ContactNameWasUpdated = false; this.col_ContactNameWasSet = false; this.col_ContactName = System.Data.SqlTypes.SqlString.Null; this.col_TitleIdWasUpdated = false; this.col_TitleIdWasSet = false; this.col_TitleId = System.Data.SqlTypes.SqlInt32.Null; this.col_AddressWasUpdated = false; this.col_AddressWasSet = false; this.col_Address = System.Data.SqlTypes.SqlString.Null; this.col_CityWasUpdated = false; this.col_CityWasSet = false; this.col_City = System.Data.SqlTypes.SqlString.Null; this.col_PostalCodeWasUpdated = false; this.col_PostalCodeWasSet = false; this.col_PostalCode = System.Data.SqlTypes.SqlString.Null; this.col_PhoneWasUpdated = false; this.col_PhoneWasSet = false; this.col_Phone = System.Data.SqlTypes.SqlString.Null; this.col_EmailWasUpdated = false; this.col_EmailWasSet = false; this.col_Email = System.Data.SqlTypes.SqlString.Null; this.col_WebAddressWasUpdated = false; this.col_WebAddressWasSet = false; this.col_WebAddress = System.Data.SqlTypes.SqlString.Null; this.col_FaxWasUpdated = false; this.col_FaxWasSet = false; this.col_Fax = System.Data.SqlTypes.SqlString.Null; this.col_ActiveWasUpdated = false; this.col_ActiveWasSet = false; this.col_Active = System.Data.SqlTypes.SqlBoolean.Null; bool alreadyOpened = false; Params.spS_Customers Param = new Params.spS_Customers(true); Param.CommandTimeOut = this.selectCommandTimeOut; switch (this.lastKnownConnectionType) { case Bob.DataClasses.ConnectionType.ConnectionString: Param.SetUpConnection(this.connectionString); break; case Bob.DataClasses.ConnectionType.SqlConnection: Param.SetUpConnection(this.sqlConnection); alreadyOpened = (this.sqlConnection.State == System.Data.ConnectionState.Open); break; case Bob.DataClasses.ConnectionType.SqlTransaction: Param.SetUpConnection(this.sqlTransaction); break; } if (!this.col_CustomerID.IsNull) { Param.Param_CustomerID = this.col_CustomerID; } System.Data.SqlClient.SqlDataReader sqlDataReader = null; SPs.spS_Customers Sp = new SPs.spS_Customers(false); if (Sp.Execute(ref Param, out sqlDataReader)) { if (sqlDataReader.Read()) { if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_CompanyName.ColumnIndex)) { this.col_CompanyName = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_CompanyName.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_ContactName.ColumnIndex)) { this.col_ContactName = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_ContactName.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_TitleId.ColumnIndex)) { this.col_TitleId = sqlDataReader.GetSqlInt32(SPs.spS_Customers.Resultset1.Fields.Column_TitleId.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Address.ColumnIndex)) { this.col_Address = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_Address.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_City.ColumnIndex)) { this.col_City = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_City.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_PostalCode.ColumnIndex)) { this.col_PostalCode = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_PostalCode.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Phone.ColumnIndex)) { this.col_Phone = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_Phone.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Email.ColumnIndex)) { this.col_Email = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_Email.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_WebAddress.ColumnIndex)) { this.col_WebAddress = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_WebAddress.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Fax.ColumnIndex)) { this.col_Fax = sqlDataReader.GetSqlString(SPs.spS_Customers.Resultset1.Fields.Column_Fax.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_Customers.Resultset1.Fields.Column_Active.ColumnIndex)) { this.col_Active = sqlDataReader.GetSqlBoolean(SPs.spS_Customers.Resultset1.Fields.Column_Active.ColumnIndex); } if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } CloseConnection(Sp.Connection, alreadyOpened); this.recordIsLoaded = true; return(true); } else { if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } CloseConnection(Sp.Connection, alreadyOpened); this.recordIsLoaded = false; return(false); } } else { if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } CloseConnection(Sp.Connection, alreadyOpened); throw new Bob.DataClasses.CustomException(Param, "Bob.BusinessComponents.Customer", "Refresh"); } }
private static MembershipEntry ConvertFromRow(SqlDataReader results, out string eTag, out int tableVersion, out string versionETag) { var entry = new MembershipEntry(); int port = results.GetInt32(PortIdx); int gen = results.GetInt32(GenerationIdx); entry.SiloAddress = SiloAddress.New(new IPEndPoint(IPAddress.Parse(results.GetString(AddressIdx)), port), gen); entry.HostName = results.GetString(HostNameIdx); entry.Status = (SiloStatus)results.GetInt32(StatusIdx); if (!results.GetSqlInt32(ProxyPortIdx).IsNull) entry.ProxyPort = results.GetInt32(ProxyPortIdx); if (!results.GetSqlBoolean(PrimaryIdx).IsNull) entry.IsPrimary = results.GetBoolean(PrimaryIdx); entry.RoleName = results.GetString(RoleNameIdx); entry.InstanceName = results.GetString(InstanceNameIdx); if (!results.GetSqlInt32(UpdateZoneIdx).IsNull) entry.UpdateZone = results.GetInt32(UpdateZoneIdx); if (!results.GetSqlInt32(FaultZoneIdx).IsNull) entry.FaultZone = results.GetInt32(FaultZoneIdx); if (!results.GetSqlDateTime(StartTimeIdx).IsNull) entry.StartTime = results.GetDateTime(StartTimeIdx); if (!results.GetSqlDateTime(IAmAliveTimeIdx).IsNull) entry.IAmAliveTime = results.GetDateTime(IAmAliveTimeIdx); eTag = results.GetString(ETagIdx); tableVersion = (int)results.GetInt64(VersionIdx); versionETag = results.GetString(VersionETagIdx); var suspectingSilosString = results.GetSqlString(SuspectingSilosIdx); var suspectingTimesString = results.GetSqlString(SuspectingTimesIdx); List<SiloAddress> suspectingSilos = new List<SiloAddress>(); List<DateTime> suspectingTimes = new List<DateTime>(); if (!suspectingSilosString.IsNull && !string.IsNullOrEmpty(suspectingSilosString.Value)) { string[] silos = suspectingSilosString.Value.Split('|'); foreach (string silo in silos) { suspectingSilos.Add(SiloAddress.FromParsableString(silo)); } } if (!suspectingTimesString.IsNull && !string.IsNullOrEmpty(suspectingTimesString.Value)) { string[] times = suspectingTimesString.Value.Split('|'); foreach (string time in times) { suspectingTimes.Add(TraceLogger.ParseDate(time)); } } if (suspectingSilos.Count != suspectingTimes.Count) throw new OrleansException(String.Format("SuspectingSilos.Length of {0} as read from SQL table is not eqaul to SuspectingTimes.Length of {1}", suspectingSilos.Count, suspectingTimes.Count)); for (int i = 0; i < suspectingSilos.Count; i++) { entry.AddSuspector(suspectingSilos[i], suspectingTimes[i]); } return entry; }
/// <summary> /// [To be supplied.] /// </summary> /// <returns>[To be supplied.]</returns> public bool Refresh() { this.displayName = null; this.col_Ord_DatOrderedOnWasUpdated = false; this.col_Ord_DatOrderedOnWasSet = false; this.col_Ord_DatOrderedOn = System.Data.SqlTypes.SqlDateTime.Null; this.col_Ord_LngCustomerIDWasUpdated = false; this.col_Ord_LngCustomerIDWasSet = false; this.col_Ord_LngCustomerID = System.Data.SqlTypes.SqlInt32.Null; this.col_Ord_CurTotalWasUpdated = false; this.col_Ord_CurTotalWasSet = false; this.col_Ord_CurTotal = System.Data.SqlTypes.SqlMoney.Null; bool alreadyOpened = false; Params.spS_tblOrder Param = new Params.spS_tblOrder(true); Param.CommandTimeOut = this.selectCommandTimeOut; switch (this.lastKnownConnectionType) { case OlymarsDemo.DataClasses.ConnectionType.ConnectionString: Param.SetUpConnection(this.connectionString); break; case OlymarsDemo.DataClasses.ConnectionType.SqlConnection: Param.SetUpConnection(this.sqlConnection); alreadyOpened = (this.sqlConnection.State == System.Data.ConnectionState.Open); break; case OlymarsDemo.DataClasses.ConnectionType.SqlTransaction: Param.SetUpConnection(this.sqlTransaction); break; } if (!this.col_Ord_GuidID.IsNull) { Param.Param_Ord_GuidID = this.col_Ord_GuidID; } System.Data.SqlClient.SqlDataReader sqlDataReader = null; SPs.spS_tblOrder Sp = new SPs.spS_tblOrder(false); if (Sp.Execute(ref Param, out sqlDataReader)) { if (sqlDataReader.Read()) { if (!sqlDataReader.IsDBNull(SPs.spS_tblOrder.Resultset1.Fields.Column_Ord_DatOrderedOn.ColumnIndex)) { this.col_Ord_DatOrderedOn = sqlDataReader.GetSqlDateTime(SPs.spS_tblOrder.Resultset1.Fields.Column_Ord_DatOrderedOn.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_tblOrder.Resultset1.Fields.Column_Ord_LngCustomerID.ColumnIndex)) { this.col_Ord_LngCustomerID = sqlDataReader.GetSqlInt32(SPs.spS_tblOrder.Resultset1.Fields.Column_Ord_LngCustomerID.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_tblOrder.Resultset1.Fields.Column_Ord_CurTotal.ColumnIndex)) { this.col_Ord_CurTotal = sqlDataReader.GetSqlMoney(SPs.spS_tblOrder.Resultset1.Fields.Column_Ord_CurTotal.ColumnIndex); } if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } CloseConnection(Sp.Connection, alreadyOpened); this.recordIsLoaded = true; return(true); } else { if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } CloseConnection(Sp.Connection, alreadyOpened); this.recordIsLoaded = false; return(false); } } else { if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } CloseConnection(Sp.Connection, alreadyOpened); throw new OlymarsDemo.DataClasses.CustomException(Param, "OlymarsDemo.BusinessComponents.tblOrder_Record", "Refresh"); } }
/// <summary> /// [To be supplied.] /// </summary> /// <returns>[To be supplied.]</returns> public bool Refresh() { this.displayName = null; this.col_JobIdWasUpdated = false; this.col_JobIdWasSet = false; this.col_JobId = System.Data.SqlTypes.SqlInt32.Null; this.col_DescriptionWasUpdated = false; this.col_DescriptionWasSet = false; this.col_Description = System.Data.SqlTypes.SqlString.Null; this.col_JobPartTypeIdWasUpdated = false; this.col_JobPartTypeIdWasSet = false; this.col_JobPartTypeId = System.Data.SqlTypes.SqlInt32.Null; this.col_UnitsWasUpdated = false; this.col_UnitsWasSet = false; this.col_Units = System.Data.SqlTypes.SqlDecimal.Null; this.col_PricePerUnitWasUpdated = false; this.col_PricePerUnitWasSet = false; this.col_PricePerUnit = System.Data.SqlTypes.SqlMoney.Null; this.col_TotalPriceWasUpdated = false; this.col_TotalPriceWasSet = false; this.col_TotalPrice = System.Data.SqlTypes.SqlMoney.Null; bool alreadyOpened = false; Params.spS_JobPart Param = new Params.spS_JobPart(true); Param.CommandTimeOut = this.selectCommandTimeOut; switch (this.lastKnownConnectionType) { case Bob.DataClasses.ConnectionType.ConnectionString: Param.SetUpConnection(this.connectionString); break; case Bob.DataClasses.ConnectionType.SqlConnection: Param.SetUpConnection(this.sqlConnection); alreadyOpened = (this.sqlConnection.State == System.Data.ConnectionState.Open); break; case Bob.DataClasses.ConnectionType.SqlTransaction: Param.SetUpConnection(this.sqlTransaction); break; } if (!this.col_JobPartId.IsNull) { Param.Param_JobPartId = this.col_JobPartId; } System.Data.SqlClient.SqlDataReader sqlDataReader = null; SPs.spS_JobPart Sp = new SPs.spS_JobPart(false); if (Sp.Execute(ref Param, out sqlDataReader)) { if (sqlDataReader.Read()) { if (!sqlDataReader.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_JobId.ColumnIndex)) { this.col_JobId = sqlDataReader.GetSqlInt32(SPs.spS_JobPart.Resultset1.Fields.Column_JobId.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_Description.ColumnIndex)) { this.col_Description = sqlDataReader.GetSqlString(SPs.spS_JobPart.Resultset1.Fields.Column_Description.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_JobPartTypeId.ColumnIndex)) { this.col_JobPartTypeId = sqlDataReader.GetSqlInt32(SPs.spS_JobPart.Resultset1.Fields.Column_JobPartTypeId.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_Units.ColumnIndex)) { this.col_Units = sqlDataReader.GetSqlDecimal(SPs.spS_JobPart.Resultset1.Fields.Column_Units.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_PricePerUnit.ColumnIndex)) { this.col_PricePerUnit = sqlDataReader.GetSqlMoney(SPs.spS_JobPart.Resultset1.Fields.Column_PricePerUnit.ColumnIndex); } if (!sqlDataReader.IsDBNull(SPs.spS_JobPart.Resultset1.Fields.Column_TotalPrice.ColumnIndex)) { this.col_TotalPrice = sqlDataReader.GetSqlMoney(SPs.spS_JobPart.Resultset1.Fields.Column_TotalPrice.ColumnIndex); } if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } CloseConnection(Sp.Connection, alreadyOpened); this.recordIsLoaded = true; return(true); } else { if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } CloseConnection(Sp.Connection, alreadyOpened); this.recordIsLoaded = false; return(false); } } else { if (sqlDataReader != null && !sqlDataReader.IsClosed) { sqlDataReader.Close(); } CloseConnection(Sp.Connection, alreadyOpened); throw new Bob.DataClasses.CustomException(Param, "Bob.BusinessComponents.JobPart_Record", "Refresh"); } }
public void GetInt32Test () { if (ClientVersion == 7) cmd.CommandText = string.Format (query, "int", "int", "decimal1"); else cmd.CommandText = string.Format (query, "int", "int", "bigint"); reader = cmd.ExecuteReader (); reader.Read (); // Test for standard exceptions GetMethodTests("Int32"); // Test if data is returned correctly Assert.AreEqual (numericRow["type_int"], reader.GetInt32(0), "#2 DataValidation Failed"); // Test for standard exceptions GetMethodTests("SqlInt32"); // Test if data is returned correctly Assert.AreEqual (numericRow["type_int"], reader.GetSqlInt32(0).Value, "#4 DataValidation Failed"); reader.Close (); }