public void Export_HumanResources_Shift() { DokdexClient client = new DokdexClient("http://localhost:6858/"); if (client.Schema.Exists("AdventureWorks2012:HumanResources:Shift")) { return; } client.Transaction.Begin(); client.Schema.Create("AdventureWorks2012:HumanResources:Shift"); using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2012;Trusted_Connection=True;")) { connection.Open(); try { using (SqlCommand command = new SqlCommand("SELECT * FROM HumanResources.Shift", connection)) { command.CommandTimeout = 10000; command.CommandType = System.Data.CommandType.Text; using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) { int indexOfShiftID = dataReader.GetOrdinal("ShiftID"); int indexOfName = dataReader.GetOrdinal("Name"); int indexOfStartTime = dataReader.GetOrdinal("StartTime"); int indexOfEndTime = dataReader.GetOrdinal("EndTime"); int indexOfModifiedDate = dataReader.GetOrdinal("ModifiedDate"); int rowCount = 0; while (dataReader.Read() /*&& rowCount++ < 10000*/) { if (rowCount > 0 && (rowCount % 100) == 0) { Console.WriteLine("AdventureWorks2012:HumanResources:Shift: {0}", rowCount); } if (rowCount > 0 && (rowCount % 1000) == 0) { Console.WriteLine("Comitting..."); client.Transaction.Commit(); client.Transaction.Begin(); } try { client.Document.Store("AdventureWorks2012:HumanResources:Shift", new Document(new Models.HumanResources_Shift { ShiftID = dataReader.GetByte(indexOfShiftID), Name = dataReader.GetString(indexOfName), StartTime = dataReader.GetTimeSpan(indexOfStartTime), EndTime = dataReader.GetTimeSpan(indexOfEndTime), ModifiedDate = dataReader.GetDateTime(indexOfModifiedDate), })); } catch (Exception ex) { Console.WriteLine(ex.Message); } rowCount++; } } } connection.Close(); } catch { //TODO: add error handling/logging throw; } client.Transaction.Commit(); } }
public void Export_dbo_ErrorLog() { DokdexClient client = new DokdexClient("http://localhost:6858/"); if (client.Schema.Exists("AdventureWorks2012:dbo:ErrorLog")) { return; } client.Transaction.Begin(); client.Schema.Create("AdventureWorks2012:dbo:ErrorLog"); using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2012;Trusted_Connection=True;")) { connection.Open(); try { using (SqlCommand command = new SqlCommand("SELECT * FROM dbo.ErrorLog", connection)) { command.CommandTimeout = 10000; command.CommandType = System.Data.CommandType.Text; using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) { int indexOfErrorLogID = dataReader.GetOrdinal("ErrorLogID"); int indexOfErrorTime = dataReader.GetOrdinal("ErrorTime"); int indexOfUserName = dataReader.GetOrdinal("UserName"); int indexOfErrorNumber = dataReader.GetOrdinal("ErrorNumber"); int indexOfErrorSeverity = dataReader.GetOrdinal("ErrorSeverity"); int indexOfErrorState = dataReader.GetOrdinal("ErrorState"); int indexOfErrorProcedure = dataReader.GetOrdinal("ErrorProcedure"); int indexOfErrorLine = dataReader.GetOrdinal("ErrorLine"); int indexOfErrorMessage = dataReader.GetOrdinal("ErrorMessage"); int rowCount = 0; while (dataReader.Read() /*&& rowCount++ < 10000*/) { if (rowCount > 0 && (rowCount % 100) == 0) { Console.WriteLine("AdventureWorks2012:dbo:ErrorLog: {0}", rowCount); } if (rowCount > 0 && (rowCount % 1000) == 0) { Console.WriteLine("Comitting..."); client.Transaction.Commit(); client.Transaction.Begin(); } try { client.Document.Store("AdventureWorks2012:dbo:ErrorLog", new Document(new Models.dbo_ErrorLog { ErrorLogID = dataReader.GetInt32(indexOfErrorLogID), ErrorTime = dataReader.GetDateTime(indexOfErrorTime), UserName = dataReader.GetString(indexOfUserName), ErrorNumber = dataReader.GetInt32(indexOfErrorNumber), ErrorSeverity = dataReader.GetNullableInt32(indexOfErrorSeverity), ErrorState = dataReader.GetNullableInt32(indexOfErrorState), ErrorProcedure = dataReader.GetNullableString(indexOfErrorProcedure), ErrorLine = dataReader.GetNullableInt32(indexOfErrorLine), ErrorMessage = dataReader.GetString(indexOfErrorMessage), })); } catch (Exception ex) { Console.WriteLine(ex.Message); } rowCount++; } } } connection.Close(); } catch { //TODO: add error handling/logging throw; } client.Transaction.Commit(); } }
public void Export_Production_WorkOrderRouting() { DokdexClient client = new DokdexClient("http://localhost:6858/"); if (client.Schema.Exists("AdventureWorks2012:Production:WorkOrderRouting")) { return; } client.Transaction.Begin(); client.Schema.Create("AdventureWorks2012:Production:WorkOrderRouting"); using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2012;Trusted_Connection=True;")) { connection.Open(); try { using (SqlCommand command = new SqlCommand("SELECT * FROM Production.WorkOrderRouting", connection)) { command.CommandTimeout = 10000; command.CommandType = System.Data.CommandType.Text; using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) { int indexOfWorkOrderID = dataReader.GetOrdinal("WorkOrderID"); int indexOfProductID = dataReader.GetOrdinal("ProductID"); int indexOfOperationSequence = dataReader.GetOrdinal("OperationSequence"); int indexOfLocationID = dataReader.GetOrdinal("LocationID"); int indexOfScheduledStartDate = dataReader.GetOrdinal("ScheduledStartDate"); int indexOfScheduledEndDate = dataReader.GetOrdinal("ScheduledEndDate"); int indexOfActualStartDate = dataReader.GetOrdinal("ActualStartDate"); int indexOfActualEndDate = dataReader.GetOrdinal("ActualEndDate"); int indexOfActualResourceHrs = dataReader.GetOrdinal("ActualResourceHrs"); int indexOfPlannedCost = dataReader.GetOrdinal("PlannedCost"); int indexOfActualCost = dataReader.GetOrdinal("ActualCost"); int indexOfModifiedDate = dataReader.GetOrdinal("ModifiedDate"); int rowCount = 0; while (dataReader.Read() /*&& rowCount++ < 10000*/) { if (rowCount > 0 && (rowCount % 100) == 0) { Console.WriteLine("AdventureWorks2012:Production:WorkOrderRouting: {0}", rowCount); } if (rowCount > 0 && (rowCount % 1000) == 0) { Console.WriteLine("Comitting..."); client.Transaction.Commit(); client.Transaction.Begin(); } try { client.Document.Store("AdventureWorks2012:Production:WorkOrderRouting", new Document(new Models.Production_WorkOrderRouting { WorkOrderID = dataReader.GetInt32(indexOfWorkOrderID), ProductID = dataReader.GetInt32(indexOfProductID), OperationSequence = dataReader.GetInt16(indexOfOperationSequence), LocationID = dataReader.GetInt16(indexOfLocationID), ScheduledStartDate = dataReader.GetDateTime(indexOfScheduledStartDate), ScheduledEndDate = dataReader.GetDateTime(indexOfScheduledEndDate), ActualStartDate = dataReader.GetNullableDateTime(indexOfActualStartDate), ActualEndDate = dataReader.GetNullableDateTime(indexOfActualEndDate), ActualResourceHrs = dataReader.GetNullableDecimal(indexOfActualResourceHrs), PlannedCost = dataReader.GetDecimal(indexOfPlannedCost), ActualCost = dataReader.GetNullableDecimal(indexOfActualCost), ModifiedDate = dataReader.GetDateTime(indexOfModifiedDate), })); } catch (Exception ex) { Console.WriteLine(ex.Message); } rowCount++; } } } connection.Close(); } catch { //TODO: add error handling/logging throw; } client.Transaction.Commit(); } }
public void Export_Sales_SalesTerritory() { DokdexClient client = new DokdexClient("http://localhost:6858/"); if (client.Schema.Exists("AdventureWorks2012:Sales:SalesTerritory")) { return; } client.Transaction.Begin(); client.Schema.Create("AdventureWorks2012:Sales:SalesTerritory"); using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2012;Trusted_Connection=True;")) { connection.Open(); try { using (SqlCommand command = new SqlCommand("SELECT * FROM Sales.SalesTerritory", connection)) { command.CommandTimeout = 10000; command.CommandType = System.Data.CommandType.Text; using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) { int indexOfTerritoryID = dataReader.GetOrdinal("TerritoryID"); int indexOfName = dataReader.GetOrdinal("Name"); int indexOfCountryRegionCode = dataReader.GetOrdinal("CountryRegionCode"); int indexOfGroup = dataReader.GetOrdinal("Group"); int indexOfSalesYTD = dataReader.GetOrdinal("SalesYTD"); int indexOfSalesLastYear = dataReader.GetOrdinal("SalesLastYear"); int indexOfCostYTD = dataReader.GetOrdinal("CostYTD"); int indexOfCostLastYear = dataReader.GetOrdinal("CostLastYear"); int indexOfrowguid = dataReader.GetOrdinal("rowguid"); int indexOfModifiedDate = dataReader.GetOrdinal("ModifiedDate"); int rowCount = 0; while (dataReader.Read() /*&& rowCount++ < 10000*/) { if (rowCount > 0 && (rowCount % 100) == 0) { Console.WriteLine("AdventureWorks2012:Sales:SalesTerritory: {0}", rowCount); } if (rowCount > 0 && (rowCount % 1000) == 0) { Console.WriteLine("Comitting..."); client.Transaction.Commit(); client.Transaction.Begin(); } try { client.Document.Store("AdventureWorks2012:Sales:SalesTerritory", new Document(new Models.Sales_SalesTerritory { TerritoryID = dataReader.GetInt32(indexOfTerritoryID), Name = dataReader.GetString(indexOfName), CountryRegionCode = dataReader.GetString(indexOfCountryRegionCode), Group = dataReader.GetString(indexOfGroup), SalesYTD = dataReader.GetDecimal(indexOfSalesYTD), SalesLastYear = dataReader.GetDecimal(indexOfSalesLastYear), CostYTD = dataReader.GetDecimal(indexOfCostYTD), CostLastYear = dataReader.GetDecimal(indexOfCostLastYear), rowguid = dataReader.GetGuid(indexOfrowguid), ModifiedDate = dataReader.GetDateTime(indexOfModifiedDate), })); } catch (Exception ex) { Console.WriteLine(ex.Message); } rowCount++; } } } connection.Close(); } catch { //TODO: add error handling/logging throw; } client.Transaction.Commit(); } }
public void Export_HumanResources_Employee() { DokdexClient client = new DokdexClient("http://localhost:6858/"); if (client.Schema.Exists("AdventureWorks2012:HumanResources:Employee")) { return; } client.Transaction.Begin(); client.Schema.Create("AdventureWorks2012:HumanResources:Employee"); using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2012;Trusted_Connection=True;")) { connection.Open(); try { using (SqlCommand command = new SqlCommand("SELECT * FROM HumanResources.Employee", connection)) { command.CommandTimeout = 10000; command.CommandType = System.Data.CommandType.Text; using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) { int indexOfBusinessEntityID = dataReader.GetOrdinal("BusinessEntityID"); int indexOfNationalIDNumber = dataReader.GetOrdinal("NationalIDNumber"); int indexOfLoginID = dataReader.GetOrdinal("LoginID"); int indexOfJobTitle = dataReader.GetOrdinal("JobTitle"); int indexOfBirthDate = dataReader.GetOrdinal("BirthDate"); int indexOfMaritalStatus = dataReader.GetOrdinal("MaritalStatus"); int indexOfGender = dataReader.GetOrdinal("Gender"); int indexOfHireDate = dataReader.GetOrdinal("HireDate"); int indexOfSalariedFlag = dataReader.GetOrdinal("SalariedFlag"); int indexOfVacationHours = dataReader.GetOrdinal("VacationHours"); int indexOfSickLeaveHours = dataReader.GetOrdinal("SickLeaveHours"); int indexOfCurrentFlag = dataReader.GetOrdinal("CurrentFlag"); int indexOfrowguid = dataReader.GetOrdinal("rowguid"); int indexOfModifiedDate = dataReader.GetOrdinal("ModifiedDate"); int rowCount = 0; while (dataReader.Read() /*&& rowCount++ < 10000*/) { if (rowCount > 0 && (rowCount % 100) == 0) { Console.WriteLine("AdventureWorks2012:HumanResources:Employee: {0}", rowCount); } if (rowCount > 0 && (rowCount % 1000) == 0) { Console.WriteLine("Comitting..."); client.Transaction.Commit(); client.Transaction.Begin(); } try { client.Document.Store("AdventureWorks2012:HumanResources:Employee", new Document(new Models.HumanResources_Employee { BusinessEntityID = dataReader.GetInt32(indexOfBusinessEntityID), NationalIDNumber = dataReader.GetString(indexOfNationalIDNumber), LoginID = dataReader.GetString(indexOfLoginID), JobTitle = dataReader.GetString(indexOfJobTitle), BirthDate = dataReader.GetDateTime(indexOfBirthDate), MaritalStatus = dataReader.GetString(indexOfMaritalStatus), Gender = dataReader.GetString(indexOfGender), HireDate = dataReader.GetDateTime(indexOfHireDate), SalariedFlag = dataReader.GetBoolean(indexOfSalariedFlag), VacationHours = dataReader.GetInt16(indexOfVacationHours), SickLeaveHours = dataReader.GetInt16(indexOfSickLeaveHours), CurrentFlag = dataReader.GetBoolean(indexOfCurrentFlag), rowguid = dataReader.GetGuid(indexOfrowguid), ModifiedDate = dataReader.GetDateTime(indexOfModifiedDate), })); } catch (Exception ex) { Console.WriteLine(ex.Message); } rowCount++; } } } connection.Close(); } catch { //TODO: add error handling/logging throw; } client.Transaction.Commit(); } }
public void Export_Production_BillOfMaterials() { DokdexClient client = new DokdexClient("http://localhost:6858/"); if (client.Schema.Exists("AdventureWorks2012:Production:BillOfMaterials")) { return; } client.Transaction.Begin(); client.Schema.Create("AdventureWorks2012:Production:BillOfMaterials"); using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2012;Trusted_Connection=True;")) { connection.Open(); try { using (SqlCommand command = new SqlCommand("SELECT * FROM Production.BillOfMaterials", connection)) { command.CommandTimeout = 10000; command.CommandType = System.Data.CommandType.Text; using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) { int indexOfBillOfMaterialsID = dataReader.GetOrdinal("BillOfMaterialsID"); int indexOfProductAssemblyID = dataReader.GetOrdinal("ProductAssemblyID"); int indexOfComponentID = dataReader.GetOrdinal("ComponentID"); int indexOfStartDate = dataReader.GetOrdinal("StartDate"); int indexOfEndDate = dataReader.GetOrdinal("EndDate"); int indexOfUnitMeasureCode = dataReader.GetOrdinal("UnitMeasureCode"); int indexOfBOMLevel = dataReader.GetOrdinal("BOMLevel"); int indexOfPerAssemblyQty = dataReader.GetOrdinal("PerAssemblyQty"); int indexOfModifiedDate = dataReader.GetOrdinal("ModifiedDate"); int rowCount = 0; while (dataReader.Read() /*&& rowCount++ < 10000*/) { if (rowCount > 0 && (rowCount % 100) == 0) { Console.WriteLine("AdventureWorks2012:Production:BillOfMaterials: {0}", rowCount); } if (rowCount > 0 && (rowCount % 1000) == 0) { Console.WriteLine("Comitting..."); client.Transaction.Commit(); client.Transaction.Begin(); } try { client.Document.Store("AdventureWorks2012:Production:BillOfMaterials", new Document(new Models.Production_BillOfMaterials { BillOfMaterialsID = dataReader.GetInt32(indexOfBillOfMaterialsID), ProductAssemblyID = dataReader.GetNullableInt32(indexOfProductAssemblyID), ComponentID = dataReader.GetInt32(indexOfComponentID), StartDate = dataReader.GetDateTime(indexOfStartDate), EndDate = dataReader.GetNullableDateTime(indexOfEndDate), UnitMeasureCode = dataReader.GetString(indexOfUnitMeasureCode), BOMLevel = dataReader.GetInt16(indexOfBOMLevel), PerAssemblyQty = dataReader.GetDecimal(indexOfPerAssemblyQty), ModifiedDate = dataReader.GetDateTime(indexOfModifiedDate), })); } catch (Exception ex) { Console.WriteLine(ex.Message); } rowCount++; } } } connection.Close(); } catch { //TODO: add error handling/logging throw; } client.Transaction.Commit(); } }
public Query(DokdexClient client) { this.client = client; }
public Document(DokdexClient client) { this.client = client; }
public void Export_Purchasing_Vendor() { DokdexClient client = new DokdexClient("http://localhost:6858/"); if (client.Schema.Exists("AdventureWorks2012:Purchasing:Vendor")) { return; } client.Transaction.Begin(); client.Schema.Create("AdventureWorks2012:Purchasing:Vendor"); using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2012;Trusted_Connection=True;")) { connection.Open(); try { using (SqlCommand command = new SqlCommand("SELECT * FROM Purchasing.Vendor", connection)) { command.CommandTimeout = 10000; command.CommandType = System.Data.CommandType.Text; using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) { int indexOfBusinessEntityID = dataReader.GetOrdinal("BusinessEntityID"); int indexOfAccountNumber = dataReader.GetOrdinal("AccountNumber"); int indexOfName = dataReader.GetOrdinal("Name"); int indexOfCreditRating = dataReader.GetOrdinal("CreditRating"); int indexOfPreferredVendorStatus = dataReader.GetOrdinal("PreferredVendorStatus"); int indexOfActiveFlag = dataReader.GetOrdinal("ActiveFlag"); int indexOfPurchasingWebServiceURL = dataReader.GetOrdinal("PurchasingWebServiceURL"); int indexOfModifiedDate = dataReader.GetOrdinal("ModifiedDate"); int rowCount = 0; while (dataReader.Read() /*&& rowCount++ < 10000*/) { if (rowCount > 0 && (rowCount % 100) == 0) { Console.WriteLine("AdventureWorks2012:Purchasing:Vendor: {0}", rowCount); } if (rowCount > 0 && (rowCount % 1000) == 0) { Console.WriteLine("Comitting..."); client.Transaction.Commit(); client.Transaction.Begin(); } try { client.Document.Store("AdventureWorks2012:Purchasing:Vendor", new Document(new Models.Purchasing_Vendor { BusinessEntityID = dataReader.GetInt32(indexOfBusinessEntityID), AccountNumber = dataReader.GetString(indexOfAccountNumber), Name = dataReader.GetString(indexOfName), CreditRating = dataReader.GetByte(indexOfCreditRating), PreferredVendorStatus = dataReader.GetBoolean(indexOfPreferredVendorStatus), ActiveFlag = dataReader.GetBoolean(indexOfActiveFlag), PurchasingWebServiceURL = dataReader.GetNullableString(indexOfPurchasingWebServiceURL), ModifiedDate = dataReader.GetDateTime(indexOfModifiedDate), })); } catch (Exception ex) { Console.WriteLine(ex.Message); } rowCount++; } } } connection.Close(); } catch { //TODO: add error handling/logging throw; } client.Transaction.Commit(); } }
public void Export_Purchasing_PurchaseOrderHeader() { DokdexClient client = new DokdexClient("http://localhost:6858/"); if (client.Schema.Exists("AdventureWorks2012:Purchasing:PurchaseOrderHeader")) { return; } client.Transaction.Begin(); client.Schema.Create("AdventureWorks2012:Purchasing:PurchaseOrderHeader"); using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2012;Trusted_Connection=True;")) { connection.Open(); try { using (SqlCommand command = new SqlCommand("SELECT * FROM Purchasing.PurchaseOrderHeader", connection)) { command.CommandTimeout = 10000; command.CommandType = System.Data.CommandType.Text; using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) { int indexOfPurchaseOrderID = dataReader.GetOrdinal("PurchaseOrderID"); int indexOfRevisionNumber = dataReader.GetOrdinal("RevisionNumber"); int indexOfStatus = dataReader.GetOrdinal("Status"); int indexOfEmployeeID = dataReader.GetOrdinal("EmployeeID"); int indexOfVendorID = dataReader.GetOrdinal("VendorID"); int indexOfShipMethodID = dataReader.GetOrdinal("ShipMethodID"); int indexOfOrderDate = dataReader.GetOrdinal("OrderDate"); int indexOfShipDate = dataReader.GetOrdinal("ShipDate"); int indexOfSubTotal = dataReader.GetOrdinal("SubTotal"); int indexOfTaxAmt = dataReader.GetOrdinal("TaxAmt"); int indexOfFreight = dataReader.GetOrdinal("Freight"); int indexOfTotalDue = dataReader.GetOrdinal("TotalDue"); int indexOfModifiedDate = dataReader.GetOrdinal("ModifiedDate"); int rowCount = 0; while (dataReader.Read() /*&& rowCount++ < 10000*/) { if (rowCount > 0 && (rowCount % 100) == 0) { Console.WriteLine("AdventureWorks2012:Purchasing:PurchaseOrderHeader: {0}", rowCount); } if (rowCount > 0 && (rowCount % 1000) == 0) { Console.WriteLine("Comitting..."); client.Transaction.Commit(); client.Transaction.Begin(); } try { client.Document.Store("AdventureWorks2012:Purchasing:PurchaseOrderHeader", new Document(new Models.Purchasing_PurchaseOrderHeader { PurchaseOrderID = dataReader.GetInt32(indexOfPurchaseOrderID), RevisionNumber = dataReader.GetByte(indexOfRevisionNumber), Status = dataReader.GetByte(indexOfStatus), EmployeeID = dataReader.GetInt32(indexOfEmployeeID), VendorID = dataReader.GetInt32(indexOfVendorID), ShipMethodID = dataReader.GetInt32(indexOfShipMethodID), OrderDate = dataReader.GetDateTime(indexOfOrderDate), ShipDate = dataReader.GetNullableDateTime(indexOfShipDate), SubTotal = dataReader.GetDecimal(indexOfSubTotal), TaxAmt = dataReader.GetDecimal(indexOfTaxAmt), Freight = dataReader.GetDecimal(indexOfFreight), TotalDue = dataReader.GetDecimal(indexOfTotalDue), ModifiedDate = dataReader.GetDateTime(indexOfModifiedDate), })); } catch (Exception ex) { Console.WriteLine(ex.Message); } rowCount++; } } } connection.Close(); } catch { //TODO: add error handling/logging throw; } client.Transaction.Commit(); } }
public Schema(DokdexClient client) { this.client = client; this.Indexes = new Indexes(client); }
public void Export_Production_Product() { DokdexClient client = new DokdexClient("http://localhost:6858/"); if (client.Schema.Exists("AdventureWorks2012:Production:Product")) { return; } client.Transaction.Begin(); client.Schema.Create("AdventureWorks2012:Production:Product"); using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2012;Trusted_Connection=True;")) { connection.Open(); try { using (SqlCommand command = new SqlCommand("SELECT * FROM Production.Product", connection)) { command.CommandTimeout = 10000; command.CommandType = System.Data.CommandType.Text; using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) { int indexOfProductID = dataReader.GetOrdinal("ProductID"); int indexOfName = dataReader.GetOrdinal("Name"); int indexOfProductNumber = dataReader.GetOrdinal("ProductNumber"); int indexOfMakeFlag = dataReader.GetOrdinal("MakeFlag"); int indexOfFinishedGoodsFlag = dataReader.GetOrdinal("FinishedGoodsFlag"); int indexOfColor = dataReader.GetOrdinal("Color"); int indexOfSafetyStockLevel = dataReader.GetOrdinal("SafetyStockLevel"); int indexOfReorderPoint = dataReader.GetOrdinal("ReorderPoint"); int indexOfStandardCost = dataReader.GetOrdinal("StandardCost"); int indexOfListPrice = dataReader.GetOrdinal("ListPrice"); int indexOfSize = dataReader.GetOrdinal("Size"); int indexOfSizeUnitMeasureCode = dataReader.GetOrdinal("SizeUnitMeasureCode"); int indexOfWeightUnitMeasureCode = dataReader.GetOrdinal("WeightUnitMeasureCode"); int indexOfWeight = dataReader.GetOrdinal("Weight"); int indexOfDaysToManufacture = dataReader.GetOrdinal("DaysToManufacture"); int indexOfProductLine = dataReader.GetOrdinal("ProductLine"); int indexOfClass = dataReader.GetOrdinal("Class"); int indexOfStyle = dataReader.GetOrdinal("Style"); int indexOfProductSubcategoryID = dataReader.GetOrdinal("ProductSubcategoryID"); int indexOfProductModelID = dataReader.GetOrdinal("ProductModelID"); int indexOfSellStartDate = dataReader.GetOrdinal("SellStartDate"); int indexOfSellEndDate = dataReader.GetOrdinal("SellEndDate"); int indexOfDiscontinuedDate = dataReader.GetOrdinal("DiscontinuedDate"); int indexOfrowguid = dataReader.GetOrdinal("rowguid"); int indexOfModifiedDate = dataReader.GetOrdinal("ModifiedDate"); int rowCount = 0; while (dataReader.Read() /*&& rowCount++ < 10000*/) { if (rowCount > 0 && (rowCount % 100) == 0) { Console.WriteLine("AdventureWorks2012:Production:Product: {0}", rowCount); } if (rowCount > 0 && (rowCount % 1000) == 0) { Console.WriteLine("Comitting..."); client.Transaction.Commit(); client.Transaction.Begin(); } try { client.Document.Store("AdventureWorks2012:Production:Product", new Document(new Models.Production_Product { ProductID = dataReader.GetInt32(indexOfProductID), Name = dataReader.GetString(indexOfName), ProductNumber = dataReader.GetString(indexOfProductNumber), MakeFlag = dataReader.GetBoolean(indexOfMakeFlag), FinishedGoodsFlag = dataReader.GetBoolean(indexOfFinishedGoodsFlag), Color = dataReader.GetNullableString(indexOfColor), SafetyStockLevel = dataReader.GetInt16(indexOfSafetyStockLevel), ReorderPoint = dataReader.GetInt16(indexOfReorderPoint), StandardCost = dataReader.GetDecimal(indexOfStandardCost), ListPrice = dataReader.GetDecimal(indexOfListPrice), Size = dataReader.GetNullableString(indexOfSize), SizeUnitMeasureCode = dataReader.GetNullableString(indexOfSizeUnitMeasureCode), WeightUnitMeasureCode = dataReader.GetNullableString(indexOfWeightUnitMeasureCode), Weight = dataReader.GetNullableDecimal(indexOfWeight), DaysToManufacture = dataReader.GetInt32(indexOfDaysToManufacture), ProductLine = dataReader.GetNullableString(indexOfProductLine), Class = dataReader.GetNullableString(indexOfClass), Style = dataReader.GetNullableString(indexOfStyle), ProductSubcategoryID = dataReader.GetNullableInt32(indexOfProductSubcategoryID), ProductModelID = dataReader.GetNullableInt32(indexOfProductModelID), SellStartDate = dataReader.GetDateTime(indexOfSellStartDate), SellEndDate = dataReader.GetNullableDateTime(indexOfSellEndDate), DiscontinuedDate = dataReader.GetNullableDateTime(indexOfDiscontinuedDate), rowguid = dataReader.GetGuid(indexOfrowguid), ModifiedDate = dataReader.GetDateTime(indexOfModifiedDate), })); } catch (Exception ex) { Console.WriteLine(ex.Message); } rowCount++; } } } connection.Close(); } catch { //TODO: add error handling/logging throw; } client.Transaction.Commit(); } }
public void Export_HumanResources_EmployeePayHistory() { DokdexClient client = new DokdexClient("http://localhost:6858/"); if (client.Schema.Exists("AdventureWorks2012:HumanResources:EmployeePayHistory")) { return; } client.Transaction.Begin(); client.Schema.Create("AdventureWorks2012:HumanResources:EmployeePayHistory"); using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2012;Trusted_Connection=True;")) { connection.Open(); try { using (SqlCommand command = new SqlCommand("SELECT * FROM HumanResources.EmployeePayHistory", connection)) { command.CommandTimeout = 10000; command.CommandType = System.Data.CommandType.Text; using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) { int indexOfBusinessEntityID = dataReader.GetOrdinal("BusinessEntityID"); int indexOfRateChangeDate = dataReader.GetOrdinal("RateChangeDate"); int indexOfRate = dataReader.GetOrdinal("Rate"); int indexOfPayFrequency = dataReader.GetOrdinal("PayFrequency"); int indexOfModifiedDate = dataReader.GetOrdinal("ModifiedDate"); int rowCount = 0; while (dataReader.Read() /*&& rowCount++ < 10000*/) { if (rowCount > 0 && (rowCount % 100) == 0) { Console.WriteLine("AdventureWorks2012:HumanResources:EmployeePayHistory: {0}", rowCount); } if (rowCount > 0 && (rowCount % 1000) == 0) { Console.WriteLine("Comitting..."); client.Transaction.Commit(); client.Transaction.Begin(); } try { client.Document.Store("AdventureWorks2012:HumanResources:EmployeePayHistory", new Document(new Models.HumanResources_EmployeePayHistory { BusinessEntityID = dataReader.GetInt32(indexOfBusinessEntityID), RateChangeDate = dataReader.GetDateTime(indexOfRateChangeDate), Rate = dataReader.GetDecimal(indexOfRate), PayFrequency = dataReader.GetByte(indexOfPayFrequency), ModifiedDate = dataReader.GetDateTime(indexOfModifiedDate), })); } catch (Exception ex) { Console.WriteLine(ex.Message); } rowCount++; } } } connection.Close(); } catch { //TODO: add error handling/logging throw; } client.Transaction.Commit(); } }
public void Export_Purchasing_ProductVendor() { DokdexClient client = new DokdexClient("http://localhost:6858/"); if (client.Schema.Exists("AdventureWorks2012:Purchasing:ProductVendor")) { return; } client.Transaction.Begin(); client.Schema.Create("AdventureWorks2012:Purchasing:ProductVendor"); using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2012;Trusted_Connection=True;")) { connection.Open(); try { using (SqlCommand command = new SqlCommand("SELECT * FROM Purchasing.ProductVendor", connection)) { command.CommandTimeout = 10000; command.CommandType = System.Data.CommandType.Text; using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) { int indexOfProductID = dataReader.GetOrdinal("ProductID"); int indexOfBusinessEntityID = dataReader.GetOrdinal("BusinessEntityID"); int indexOfAverageLeadTime = dataReader.GetOrdinal("AverageLeadTime"); int indexOfStandardPrice = dataReader.GetOrdinal("StandardPrice"); int indexOfLastReceiptCost = dataReader.GetOrdinal("LastReceiptCost"); int indexOfLastReceiptDate = dataReader.GetOrdinal("LastReceiptDate"); int indexOfMinOrderQty = dataReader.GetOrdinal("MinOrderQty"); int indexOfMaxOrderQty = dataReader.GetOrdinal("MaxOrderQty"); int indexOfOnOrderQty = dataReader.GetOrdinal("OnOrderQty"); int indexOfUnitMeasureCode = dataReader.GetOrdinal("UnitMeasureCode"); int indexOfModifiedDate = dataReader.GetOrdinal("ModifiedDate"); int rowCount = 0; while (dataReader.Read() /*&& rowCount++ < 10000*/) { if (rowCount > 0 && (rowCount % 100) == 0) { Console.WriteLine("AdventureWorks2012:Purchasing:ProductVendor: {0}", rowCount); } if (rowCount > 0 && (rowCount % 1000) == 0) { Console.WriteLine("Comitting..."); client.Transaction.Commit(); client.Transaction.Begin(); } try { client.Document.Store("AdventureWorks2012:Purchasing:ProductVendor", new Document(new Models.Purchasing_ProductVendor { ProductID = dataReader.GetInt32(indexOfProductID), BusinessEntityID = dataReader.GetInt32(indexOfBusinessEntityID), AverageLeadTime = dataReader.GetInt32(indexOfAverageLeadTime), StandardPrice = dataReader.GetDecimal(indexOfStandardPrice), LastReceiptCost = dataReader.GetNullableDecimal(indexOfLastReceiptCost), LastReceiptDate = dataReader.GetNullableDateTime(indexOfLastReceiptDate), MinOrderQty = dataReader.GetInt32(indexOfMinOrderQty), MaxOrderQty = dataReader.GetInt32(indexOfMaxOrderQty), OnOrderQty = dataReader.GetNullableInt32(indexOfOnOrderQty), UnitMeasureCode = dataReader.GetString(indexOfUnitMeasureCode), ModifiedDate = dataReader.GetDateTime(indexOfModifiedDate), })); } catch (Exception ex) { Console.WriteLine(ex.Message); } rowCount++; } } } connection.Close(); } catch { //TODO: add error handling/logging throw; } client.Transaction.Commit(); } }
public void Export_Person_Person() { DokdexClient client = new DokdexClient("http://localhost:6858/"); if (client.Schema.Exists("AdventureWorks2012:Person:Person")) { return; } client.Transaction.Begin(); client.Schema.Create("AdventureWorks2012:Person:Person"); using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2012;Trusted_Connection=True;")) { connection.Open(); try { using (SqlCommand command = new SqlCommand("SELECT * FROM Person.Person", connection)) { command.CommandTimeout = 10000; command.CommandType = System.Data.CommandType.Text; using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) { int indexOfBusinessEntityID = dataReader.GetOrdinal("BusinessEntityID"); int indexOfPersonType = dataReader.GetOrdinal("PersonType"); int indexOfNameStyle = dataReader.GetOrdinal("NameStyle"); int indexOfTitle = dataReader.GetOrdinal("Title"); int indexOfFirstName = dataReader.GetOrdinal("FirstName"); int indexOfMiddleName = dataReader.GetOrdinal("MiddleName"); int indexOfLastName = dataReader.GetOrdinal("LastName"); int indexOfSuffix = dataReader.GetOrdinal("Suffix"); int indexOfEmailPromotion = dataReader.GetOrdinal("EmailPromotion"); int indexOfAdditionalContactInfo = dataReader.GetOrdinal("AdditionalContactInfo"); int indexOfDemographics = dataReader.GetOrdinal("Demographics"); int indexOfrowguid = dataReader.GetOrdinal("rowguid"); int indexOfModifiedDate = dataReader.GetOrdinal("ModifiedDate"); int rowCount = 0; while (dataReader.Read() /*&& rowCount++ < 10000*/) { if (rowCount > 0 && (rowCount % 100) == 0) { Console.WriteLine("AdventureWorks2012:Person:Person: {0}", rowCount); } if (rowCount > 0 && (rowCount % 1000) == 0) { Console.WriteLine("Comitting..."); client.Transaction.Commit(); client.Transaction.Begin(); } try { client.Document.Store("AdventureWorks2012:Person:Person", new Document(new Models.Person_Person { BusinessEntityID = dataReader.GetInt32(indexOfBusinessEntityID), PersonType = dataReader.GetString(indexOfPersonType), NameStyle = dataReader.GetBoolean(indexOfNameStyle), Title = dataReader.GetNullableString(indexOfTitle), FirstName = dataReader.GetString(indexOfFirstName), MiddleName = dataReader.GetNullableString(indexOfMiddleName), LastName = dataReader.GetString(indexOfLastName), Suffix = dataReader.GetNullableString(indexOfSuffix), EmailPromotion = dataReader.GetInt32(indexOfEmailPromotion), AdditionalContactInfo = dataReader.GetNullableString(indexOfAdditionalContactInfo), Demographics = dataReader.GetNullableString(indexOfDemographics), rowguid = dataReader.GetGuid(indexOfrowguid), ModifiedDate = dataReader.GetDateTime(indexOfModifiedDate), })); } catch (Exception ex) { Console.WriteLine(ex.Message); } rowCount++; } } } connection.Close(); } catch { //TODO: add error handling/logging throw; } client.Transaction.Commit(); } }
public Indexes(DokdexClient client) { this.client = client; }
public void Export_Person_Address() { DokdexClient client = new DokdexClient("http://localhost:6858/"); if (client.Schema.Exists("AdventureWorks2012:Person:Address")) { return; } client.Transaction.Begin(); client.Schema.Create("AdventureWorks2012:Person:Address"); using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2012;Trusted_Connection=True;")) { connection.Open(); try { using (SqlCommand command = new SqlCommand("SELECT * FROM Person.Address", connection)) { command.CommandTimeout = 10000; command.CommandType = System.Data.CommandType.Text; using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) { int indexOfAddressID = dataReader.GetOrdinal("AddressID"); int indexOfAddressLine1 = dataReader.GetOrdinal("AddressLine1"); int indexOfAddressLine2 = dataReader.GetOrdinal("AddressLine2"); int indexOfCity = dataReader.GetOrdinal("City"); int indexOfStateProvinceID = dataReader.GetOrdinal("StateProvinceID"); int indexOfPostalCode = dataReader.GetOrdinal("PostalCode"); int indexOfrowguid = dataReader.GetOrdinal("rowguid"); int indexOfModifiedDate = dataReader.GetOrdinal("ModifiedDate"); int rowCount = 0; while (dataReader.Read() /*&& rowCount++ < 10000*/) { if (rowCount > 0 && (rowCount % 100) == 0) { Console.WriteLine("AdventureWorks2012:Person:Address: {0}", rowCount); } if (rowCount > 0 && (rowCount % 1000) == 0) { Console.WriteLine("Comitting..."); client.Transaction.Commit(); client.Transaction.Begin(); } try { client.Document.Store("AdventureWorks2012:Person:Address", new Document(new Models.Person_Address { AddressID = dataReader.GetInt32(indexOfAddressID), AddressLine1 = dataReader.GetString(indexOfAddressLine1), AddressLine2 = dataReader.GetNullableString(indexOfAddressLine2), City = dataReader.GetString(indexOfCity), StateProvinceID = dataReader.GetInt32(indexOfStateProvinceID), PostalCode = dataReader.GetString(indexOfPostalCode), rowguid = dataReader.GetGuid(indexOfrowguid), ModifiedDate = dataReader.GetDateTime(indexOfModifiedDate), })); } catch (Exception ex) { Console.WriteLine(ex.Message); } rowCount++; } } } connection.Close(); } catch { //TODO: add error handling/logging throw; } client.Transaction.Commit(); } }
public void Export_Sales_CreditCard() { DokdexClient client = new DokdexClient("http://localhost:6858/"); if (client.Schema.Exists("AdventureWorks2012:Sales:CreditCard")) { return; } client.Transaction.Begin(); client.Schema.Create("AdventureWorks2012:Sales:CreditCard"); using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2012;Trusted_Connection=True;")) { connection.Open(); try { using (SqlCommand command = new SqlCommand("SELECT * FROM Sales.CreditCard", connection)) { command.CommandTimeout = 10000; command.CommandType = System.Data.CommandType.Text; using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) { int indexOfCreditCardID = dataReader.GetOrdinal("CreditCardID"); int indexOfCardType = dataReader.GetOrdinal("CardType"); int indexOfCardNumber = dataReader.GetOrdinal("CardNumber"); int indexOfExpMonth = dataReader.GetOrdinal("ExpMonth"); int indexOfExpYear = dataReader.GetOrdinal("ExpYear"); int indexOfModifiedDate = dataReader.GetOrdinal("ModifiedDate"); int rowCount = 0; while (dataReader.Read() /*&& rowCount++ < 10000*/) { if (rowCount > 0 && (rowCount % 100) == 0) { Console.WriteLine("AdventureWorks2012:Sales:CreditCard: {0}", rowCount); } if (rowCount > 0 && (rowCount % 1000) == 0) { Console.WriteLine("Comitting..."); client.Transaction.Commit(); client.Transaction.Begin(); } try { client.Document.Store("AdventureWorks2012:Sales:CreditCard", new Document(new Models.Sales_CreditCard { CreditCardID = dataReader.GetInt32(indexOfCreditCardID), CardType = dataReader.GetString(indexOfCardType), CardNumber = dataReader.GetString(indexOfCardNumber), ExpMonth = dataReader.GetByte(indexOfExpMonth), ExpYear = dataReader.GetInt16(indexOfExpYear), ModifiedDate = dataReader.GetDateTime(indexOfModifiedDate), })); } catch (Exception ex) { Console.WriteLine(ex.Message); } rowCount++; } } } connection.Close(); } catch { //TODO: add error handling/logging throw; } client.Transaction.Commit(); } }
public void Export_Sales_SalesOrderDetail() { DokdexClient client = new DokdexClient("http://localhost:6858/"); if (client.Schema.Exists("AdventureWorks2012:Sales:SalesOrderDetail")) { return; } client.Transaction.Begin(); client.Schema.Create("AdventureWorks2012:Sales:SalesOrderDetail"); using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2012;Trusted_Connection=True;")) { connection.Open(); try { using (SqlCommand command = new SqlCommand("SELECT * FROM Sales.SalesOrderDetail", connection)) { command.CommandTimeout = 10000; command.CommandType = System.Data.CommandType.Text; using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) { int indexOfSalesOrderID = dataReader.GetOrdinal("SalesOrderID"); int indexOfSalesOrderDetailID = dataReader.GetOrdinal("SalesOrderDetailID"); int indexOfCarrierTrackingNumber = dataReader.GetOrdinal("CarrierTrackingNumber"); int indexOfOrderQty = dataReader.GetOrdinal("OrderQty"); int indexOfProductID = dataReader.GetOrdinal("ProductID"); int indexOfSpecialOfferID = dataReader.GetOrdinal("SpecialOfferID"); int indexOfUnitPrice = dataReader.GetOrdinal("UnitPrice"); int indexOfUnitPriceDiscount = dataReader.GetOrdinal("UnitPriceDiscount"); int indexOfLineTotal = dataReader.GetOrdinal("LineTotal"); int indexOfrowguid = dataReader.GetOrdinal("rowguid"); int indexOfModifiedDate = dataReader.GetOrdinal("ModifiedDate"); int rowCount = 0; while (dataReader.Read() /*&& rowCount++ < 10000*/) { if (rowCount > 0 && (rowCount % 100) == 0) { Console.WriteLine("AdventureWorks2012:Sales:SalesOrderDetail: {0}", rowCount); } if (rowCount > 0 && (rowCount % 1000) == 0) { Console.WriteLine("Comitting..."); client.Transaction.Commit(); client.Transaction.Begin(); } try { client.Document.Store("AdventureWorks2012:Sales:SalesOrderDetail", new Document(new Models.Sales_SalesOrderDetail { SalesOrderID = dataReader.GetInt32(indexOfSalesOrderID), SalesOrderDetailID = dataReader.GetInt32(indexOfSalesOrderDetailID), CarrierTrackingNumber = dataReader.GetNullableString(indexOfCarrierTrackingNumber), OrderQty = dataReader.GetInt16(indexOfOrderQty), ProductID = dataReader.GetInt32(indexOfProductID), SpecialOfferID = dataReader.GetInt32(indexOfSpecialOfferID), UnitPrice = dataReader.GetDecimal(indexOfUnitPrice), UnitPriceDiscount = dataReader.GetDecimal(indexOfUnitPriceDiscount), LineTotal = dataReader.GetDecimal(indexOfLineTotal), rowguid = dataReader.GetGuid(indexOfrowguid), ModifiedDate = dataReader.GetDateTime(indexOfModifiedDate), })); } catch (Exception ex) { Console.WriteLine(ex.Message); } rowCount++; } } } connection.Close(); } catch { //TODO: add error handling/logging throw; } client.Transaction.Commit(); } }
public void Export_Sales_SalesOrderHeader() { DokdexClient client = new DokdexClient("http://localhost:6858/"); if (client.Schema.Exists("AdventureWorks2012:Sales:SalesOrderHeader")) { return; } client.Transaction.Begin(); client.Schema.Create("AdventureWorks2012:Sales:SalesOrderHeader"); using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2012;Trusted_Connection=True;")) { connection.Open(); try { using (SqlCommand command = new SqlCommand("SELECT * FROM Sales.SalesOrderHeader", connection)) { command.CommandTimeout = 10000; command.CommandType = System.Data.CommandType.Text; using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) { int indexOfSalesOrderID = dataReader.GetOrdinal("SalesOrderID"); int indexOfRevisionNumber = dataReader.GetOrdinal("RevisionNumber"); int indexOfOrderDate = dataReader.GetOrdinal("OrderDate"); int indexOfDueDate = dataReader.GetOrdinal("DueDate"); int indexOfShipDate = dataReader.GetOrdinal("ShipDate"); int indexOfStatus = dataReader.GetOrdinal("Status"); int indexOfOnlineOrderFlag = dataReader.GetOrdinal("OnlineOrderFlag"); int indexOfSalesOrderNumber = dataReader.GetOrdinal("SalesOrderNumber"); int indexOfPurchaseOrderNumber = dataReader.GetOrdinal("PurchaseOrderNumber"); int indexOfAccountNumber = dataReader.GetOrdinal("AccountNumber"); int indexOfCustomerID = dataReader.GetOrdinal("CustomerID"); int indexOfSalesPersonID = dataReader.GetOrdinal("SalesPersonID"); int indexOfTerritoryID = dataReader.GetOrdinal("TerritoryID"); int indexOfBillToAddressID = dataReader.GetOrdinal("BillToAddressID"); int indexOfShipToAddressID = dataReader.GetOrdinal("ShipToAddressID"); int indexOfShipMethodID = dataReader.GetOrdinal("ShipMethodID"); int indexOfCreditCardID = dataReader.GetOrdinal("CreditCardID"); int indexOfCreditCardApprovalCode = dataReader.GetOrdinal("CreditCardApprovalCode"); int indexOfCurrencyRateID = dataReader.GetOrdinal("CurrencyRateID"); int indexOfSubTotal = dataReader.GetOrdinal("SubTotal"); int indexOfTaxAmt = dataReader.GetOrdinal("TaxAmt"); int indexOfFreight = dataReader.GetOrdinal("Freight"); int indexOfTotalDue = dataReader.GetOrdinal("TotalDue"); int indexOfComment = dataReader.GetOrdinal("Comment"); int indexOfrowguid = dataReader.GetOrdinal("rowguid"); int indexOfModifiedDate = dataReader.GetOrdinal("ModifiedDate"); int rowCount = 0; while (dataReader.Read() /*&& rowCount++ < 10000*/) { if (rowCount > 0 && (rowCount % 100) == 0) { Console.WriteLine("AdventureWorks2012:Sales:SalesOrderHeader: {0}", rowCount); } if (rowCount > 0 && (rowCount % 1000) == 0) { Console.WriteLine("Comitting..."); client.Transaction.Commit(); client.Transaction.Begin(); } try { client.Document.Store("AdventureWorks2012:Sales:SalesOrderHeader", new Document(new Models.Sales_SalesOrderHeader { SalesOrderID = dataReader.GetInt32(indexOfSalesOrderID), RevisionNumber = dataReader.GetByte(indexOfRevisionNumber), OrderDate = dataReader.GetDateTime(indexOfOrderDate), DueDate = dataReader.GetDateTime(indexOfDueDate), ShipDate = dataReader.GetNullableDateTime(indexOfShipDate), Status = dataReader.GetByte(indexOfStatus), OnlineOrderFlag = dataReader.GetBoolean(indexOfOnlineOrderFlag), SalesOrderNumber = dataReader.GetString(indexOfSalesOrderNumber), PurchaseOrderNumber = dataReader.GetNullableString(indexOfPurchaseOrderNumber), AccountNumber = dataReader.GetNullableString(indexOfAccountNumber), CustomerID = dataReader.GetInt32(indexOfCustomerID), SalesPersonID = dataReader.GetNullableInt32(indexOfSalesPersonID), TerritoryID = dataReader.GetNullableInt32(indexOfTerritoryID), BillToAddressID = dataReader.GetInt32(indexOfBillToAddressID), ShipToAddressID = dataReader.GetInt32(indexOfShipToAddressID), ShipMethodID = dataReader.GetInt32(indexOfShipMethodID), CreditCardID = dataReader.GetNullableInt32(indexOfCreditCardID), CreditCardApprovalCode = dataReader.GetNullableString(indexOfCreditCardApprovalCode), CurrencyRateID = dataReader.GetNullableInt32(indexOfCurrencyRateID), SubTotal = dataReader.GetDecimal(indexOfSubTotal), TaxAmt = dataReader.GetDecimal(indexOfTaxAmt), Freight = dataReader.GetDecimal(indexOfFreight), TotalDue = dataReader.GetDecimal(indexOfTotalDue), Comment = dataReader.GetNullableString(indexOfComment), rowguid = dataReader.GetGuid(indexOfrowguid), ModifiedDate = dataReader.GetDateTime(indexOfModifiedDate), })); } catch (Exception ex) { Console.WriteLine(ex.Message); } rowCount++; } } } connection.Close(); } catch { //TODO: add error handling/logging throw; } client.Transaction.Commit(); } }
public void Export_Production_Document() { DokdexClient client = new DokdexClient("http://localhost:6858/"); if (client.Schema.Exists("AdventureWorks2012:Production:Document")) { return; } client.Transaction.Begin(); client.Schema.Create("AdventureWorks2012:Production:Document"); using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2012;Trusted_Connection=True;")) { connection.Open(); try { using (SqlCommand command = new SqlCommand("SELECT * FROM Production.Document", connection)) { command.CommandTimeout = 10000; command.CommandType = System.Data.CommandType.Text; using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) { int indexOfId = dataReader.GetOrdinal("Id"); int indexOfTitle = dataReader.GetOrdinal("Title"); int indexOfOwner = dataReader.GetOrdinal("Owner"); int indexOfFolderFlag = dataReader.GetOrdinal("FolderFlag"); int indexOfFileName = dataReader.GetOrdinal("FileName"); int indexOfFileExtension = dataReader.GetOrdinal("FileExtension"); int indexOfRevision = dataReader.GetOrdinal("Revision"); int indexOfChangeNumber = dataReader.GetOrdinal("ChangeNumber"); int indexOfStatus = dataReader.GetOrdinal("Status"); int indexOfDocumentSummary = dataReader.GetOrdinal("DocumentSummary"); int indexOfDocument = dataReader.GetOrdinal("Document"); int indexOfrowguid = dataReader.GetOrdinal("rowguid"); int indexOfModifiedDate = dataReader.GetOrdinal("ModifiedDate"); int rowCount = 0; while (dataReader.Read() /*&& rowCount++ < 10000*/) { if (rowCount > 0 && (rowCount % 100) == 0) { Console.WriteLine("AdventureWorks2012:Production:Document: {0}", rowCount); } if (rowCount > 0 && (rowCount % 1000) == 0) { Console.WriteLine("Comitting..."); client.Transaction.Commit(); client.Transaction.Begin(); } try { client.Document.Store("AdventureWorks2012:Production:Document", new Document(new Models.Production_Document { Id = dataReader.GetInt32(indexOfId), Title = dataReader.GetString(indexOfTitle), Owner = dataReader.GetInt32(indexOfOwner), FolderFlag = dataReader.GetBoolean(indexOfFolderFlag), FileName = dataReader.GetString(indexOfFileName), FileExtension = dataReader.GetString(indexOfFileExtension), Revision = dataReader.GetString(indexOfRevision), ChangeNumber = dataReader.GetInt32(indexOfChangeNumber), Status = dataReader.GetByte(indexOfStatus), DocumentSummary = dataReader.GetNullableString(indexOfDocumentSummary), Document = dataReader.GetNullableByteArray(indexOfDocument), rowguid = dataReader.GetGuid(indexOfrowguid), ModifiedDate = dataReader.GetDateTime(indexOfModifiedDate), })); } catch (Exception ex) { Console.WriteLine(ex.Message); } rowCount++; } } } connection.Close(); } catch { //TODO: add error handling/logging throw; } client.Transaction.Commit(); } }
public void Export_Sales_SpecialOffer() { DokdexClient client = new DokdexClient("http://localhost:6858/"); if (client.Schema.Exists("AdventureWorks2012:Sales:SpecialOffer")) { return; } client.Transaction.Begin(); client.Schema.Create("AdventureWorks2012:Sales:SpecialOffer"); using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2012;Trusted_Connection=True;")) { connection.Open(); try { using (SqlCommand command = new SqlCommand("SELECT * FROM Sales.SpecialOffer", connection)) { command.CommandTimeout = 10000; command.CommandType = System.Data.CommandType.Text; using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) { int indexOfSpecialOfferID = dataReader.GetOrdinal("SpecialOfferID"); int indexOfDescription = dataReader.GetOrdinal("Description"); int indexOfDiscountPct = dataReader.GetOrdinal("DiscountPct"); int indexOfType = dataReader.GetOrdinal("Type"); int indexOfCategory = dataReader.GetOrdinal("Category"); int indexOfStartDate = dataReader.GetOrdinal("StartDate"); int indexOfEndDate = dataReader.GetOrdinal("EndDate"); int indexOfMinQty = dataReader.GetOrdinal("MinQty"); int indexOfMaxQty = dataReader.GetOrdinal("MaxQty"); int indexOfrowguid = dataReader.GetOrdinal("rowguid"); int indexOfModifiedDate = dataReader.GetOrdinal("ModifiedDate"); int rowCount = 0; while (dataReader.Read() /*&& rowCount++ < 10000*/) { if (rowCount > 0 && (rowCount % 100) == 0) { Console.WriteLine("AdventureWorks2012:Sales:SpecialOffer: {0}", rowCount); } if (rowCount > 0 && (rowCount % 1000) == 0) { Console.WriteLine("Comitting..."); client.Transaction.Commit(); client.Transaction.Begin(); } try { client.Document.Store("AdventureWorks2012:Sales:SpecialOffer", new Document(new Models.Sales_SpecialOffer { SpecialOfferID = dataReader.GetInt32(indexOfSpecialOfferID), Description = dataReader.GetString(indexOfDescription), DiscountPct = dataReader.GetDecimal(indexOfDiscountPct), Type = dataReader.GetString(indexOfType), Category = dataReader.GetString(indexOfCategory), StartDate = dataReader.GetDateTime(indexOfStartDate), EndDate = dataReader.GetDateTime(indexOfEndDate), MinQty = dataReader.GetInt32(indexOfMinQty), MaxQty = dataReader.GetNullableInt32(indexOfMaxQty), rowguid = dataReader.GetGuid(indexOfrowguid), ModifiedDate = dataReader.GetDateTime(indexOfModifiedDate), })); } catch (Exception ex) { Console.WriteLine(ex.Message); } rowCount++; } } } connection.Close(); } catch { //TODO: add error handling/logging throw; } client.Transaction.Commit(); } }
public void Export_Production_ProductDocument() { DokdexClient client = new DokdexClient("http://localhost:6858/"); if (client.Schema.Exists("AdventureWorks2012:Production:ProductDocument")) { return; } client.Transaction.Begin(); client.Schema.Create("AdventureWorks2012:Production:ProductDocument"); using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2012;Trusted_Connection=True;")) { connection.Open(); try { using (SqlCommand command = new SqlCommand("SELECT * FROM Production.ProductDocument", connection)) { command.CommandTimeout = 10000; command.CommandType = System.Data.CommandType.Text; using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection)) { int indexOfId = dataReader.GetOrdinal("Id"); int indexOfProductID = dataReader.GetOrdinal("ProductID"); int indexOfModifiedDate = dataReader.GetOrdinal("ModifiedDate"); int indexOfDocumentId = dataReader.GetOrdinal("DocumentId"); int rowCount = 0; while (dataReader.Read() /*&& rowCount++ < 10000*/) { if (rowCount > 0 && (rowCount % 100) == 0) { Console.WriteLine("AdventureWorks2012:Production:ProductDocument: {0}", rowCount); } if (rowCount > 0 && (rowCount % 1000) == 0) { Console.WriteLine("Comitting..."); client.Transaction.Commit(); client.Transaction.Begin(); } try { client.Document.Store("AdventureWorks2012:Production:ProductDocument", new Document(new Models.Production_ProductDocument { Id = dataReader.GetInt32(indexOfId), ProductID = dataReader.GetInt32(indexOfProductID), ModifiedDate = dataReader.GetDateTime(indexOfModifiedDate), DocumentId = dataReader.GetNullableInt32(indexOfDocumentId), })); } catch (Exception ex) { Console.WriteLine(ex.Message); } rowCount++; } } } connection.Close(); } catch { //TODO: add error handling/logging throw; } client.Transaction.Commit(); } }
public Transaction(DokdexClient client) { this.client = client; }