コード例 #1
0
ファイル: Program.cs プロジェクト: NTDLS/MammutDB
 private static void DummyQuery()
 {
     using (var client = new MammutClient("https://*****:*****@ssWord!"))
     {
         client.Query.ExecuteDummy();
     }
 }
コード例 #2
0
ファイル: Program.cs プロジェクト: NTDLS/MammutDB
        public static void DumpSubWords(MammutClient client, string schema, int rootWordId)
        {
            var rand = new Random();

            var sqlConnectionStringBuilder = new SqlConnectionStringBuilder()
            {
                InitialCatalog     = "WordList",
                DataSource         = "localhost",
                IntegratedSecurity = true
            };

            using (var sqlConnection = new SqlConnection(sqlConnectionStringBuilder.ToString()))
            {
                sqlConnection.Open();

                client.Transaction.Enlist();

                client.Schema.CreateAll(schema);

                var tSQL = $"SELECT TOP 100 W.Id, W.[Text] FROM Word as W INNER JOIN [Synonym] as S ON S.TargetWordId = W.Id WHERE S.SourceWordId = {rootWordId}";
                using (var sqlCommand = new SqlCommand(tSQL, sqlConnection))
                {
                    using (var reader = sqlCommand.ExecuteReader())
                    {
                        while (reader.Read())
                        {
                            int    wordId    = (int)reader["Id"];
                            string wordText  = reader["Text"].ToString();
                            string subSchema = $"{schema}:{wordText}";

                            var cust = new Customer()
                            {
                                Name              = wordText,
                                EIN               = $"{rand.Next(10, 99)}-{rand.Next(10000, 99999)}",
                                AnnualRevenue     = rand.NextDouble() * 100000,
                                NumberOfEmployees = rand.Next(10, 1000)
                            };

                            var documentInfo = client.Document.Create(schema, cust);

                            var document = client.Document.GetById(schema, documentInfo.Id);

                            //DumpSubWords(subSchema, wordId);

                            //System.Threading.Thread.Sleep(250);
                        }

                        client.Transaction.Commit();
                    }
                }

                sqlConnection.Close();
            }
        }
コード例 #3
0
ファイル: Program.cs プロジェクト: NTDLS/MammutDB
        public static void DumpRootWords()
        {
            var sqlConnectionStringBuilder = new SqlConnectionStringBuilder()
            {
                InitialCatalog     = "WordList",
                DataSource         = "localhost",
                IntegratedSecurity = true
            };

            using (var sqlConnection = new SqlConnection(sqlConnectionStringBuilder.ToString()))
            {
                sqlConnection.Open();

                using (var client = new MammutClient("https://*****:*****@ssWord!"))
                {
                    client.Transaction.Enlist();

                    client.Schema.CreateAll("Word:Synonym");

                    var tSQL = "SELECT TOP 100 W.Id, W.[Text] FROM Word as W WHERE EXISTS (SELECT 1 FROM [Synonym] as S WHERE S.SourceWordId = W.Id)";
                    using (var sqlCommand = new SqlCommand(tSQL, sqlConnection))
                    {
                        using (var reader = sqlCommand.ExecuteReader())
                        {
                            while (reader.Read())
                            {
                                int    wordId   = (int)reader["Id"];
                                string wordText = reader["Text"].ToString();
                                string schema   = $"Word:Synonym:{wordText}";

                                client.Schema.CreateAll(schema);

                                DumpSubWords(client, schema, wordId);

                                //System.Threading.Thread.Sleep(250);
                            }
                        }
                    }

                    client.Transaction.Commit();
                }

                sqlConnection.Close();
            }
        }
コード例 #4
0
ファイル: Program.cs プロジェクト: NTDLS/MammutDB
        private static void CreateSchema()
        {
            using (var client = new MammutClient("https://*****:*****@ssWord!"))
            {
                client.Transaction.Enlist();
                client.Schema.Create("AR");
                client.Schema.Create("AR:Sales");
                client.Schema.Create("AR:Sales:Orders");
                client.Schema.Create("AR:Sales:People");
                client.Schema.Create("AR:Sales:People:Terminated");
                client.Schema.Create("AR:Customers");
                client.Schema.Create("AR:Customers:Prospects");
                client.Schema.Create("AR:Customers:Contracts");
                client.Transaction.Commit();

                //var result = connection.Client.Schema.Get("AR:Sales");
                //Console.WriteLine($"Name: {result.Name}, Id: {result.Id}, Path: {result.Path}");
            }
        }
コード例 #5
0
 public TransactionClient(MammutClient client)
     : base(client)
 {
     _client = client;
 }
コード例 #6
0
        public void Export_Sales_CurrencyRate()
        {
            using (var client = new MammutClient("https://*****:*****@ssWord!"))
            {
                //if(client.Schema.Exists("AdventureWorks2008R2:Sales:CurrencyRate"))
                //{
                //	return;
                //}

                client.Transaction.Enlist();

                client.Schema.CreateAll("AdventureWorks2008R2:Sales:CurrencyRate");

                using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2008R2;Trusted_Connection=True;"))
                {
                    connection.Open();

                    try
                    {
                        using (SqlCommand command = new SqlCommand("SELECT * FROM Sales.CurrencyRate", connection))
                        {
                            command.CommandTimeout = 10000;
                            command.CommandType    = System.Data.CommandType.Text;

                            using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                            {
                                int indexOfCurrencyRateID   = dataReader.GetOrdinal("CurrencyRateID");
                                int indexOfCurrencyRateDate = dataReader.GetOrdinal("CurrencyRateDate");
                                int indexOfFromCurrencyCode = dataReader.GetOrdinal("FromCurrencyCode");
                                int indexOfToCurrencyCode   = dataReader.GetOrdinal("ToCurrencyCode");
                                int indexOfAverageRate      = dataReader.GetOrdinal("AverageRate");
                                int indexOfEndOfDayRate     = dataReader.GetOrdinal("EndOfDayRate");
                                int indexOfModifiedDate     = dataReader.GetOrdinal("ModifiedDate");

                                int rowCount = 0;


                                while (dataReader.Read() && rowCount < 1000 /*easy replace*/)
                                {
                                    if (rowCount > 0 && (rowCount % 100) == 0)
                                    {
                                        Console.WriteLine("AdventureWorks2008R2:Sales:CurrencyRate: {0}", rowCount);
                                    }

                                    if (rowCount > 0 && (rowCount % 1000) == 0)
                                    {
                                        Console.WriteLine("Comitting...");
                                        client.Transaction.Commit();
                                        client.Transaction.Enlist();
                                    }

                                    try
                                    {
                                        client.Document.Create("AdventureWorks2008R2:Sales:CurrencyRate", new Models.Sales_CurrencyRate
                                        {
                                            CurrencyRateID   = dataReader.GetInt32(indexOfCurrencyRateID),
                                            CurrencyRateDate = dataReader.GetDateTime(indexOfCurrencyRateDate),
                                            FromCurrencyCode = dataReader.GetString(indexOfFromCurrencyCode),
                                            ToCurrencyCode   = dataReader.GetString(indexOfToCurrencyCode),
                                            AverageRate      = dataReader.GetDecimal(indexOfAverageRate),
                                            EndOfDayRate     = dataReader.GetDecimal(indexOfEndOfDayRate),
                                            ModifiedDate     = dataReader.GetDateTime(indexOfModifiedDate),
                                        });
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex.Message);
                                    }

                                    rowCount++;
                                }
                            }
                        }
                        connection.Close();
                    }
                    catch
                    {
                        //TODO: add error handling/logging
                        throw;
                    }

                    client.Transaction.Commit();
                }
            }
        }
コード例 #7
0
        public void Export_Person_BusinessEntity()
        {
            using (var client = new MammutClient("https://*****:*****@ssWord!"))
            {
                //if(client.Schema.Exists("AdventureWorks2008R2:Person:BusinessEntity"))
                //{
                //	return;
                //}

                client.Transaction.Enlist();

                client.Schema.CreateAll("AdventureWorks2008R2:Person:BusinessEntity");

                using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2008R2;Trusted_Connection=True;"))
                {
                    connection.Open();

                    try
                    {
                        using (SqlCommand command = new SqlCommand("SELECT * FROM Person.BusinessEntity", 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 indexOfrowguid          = dataReader.GetOrdinal("rowguid");
                                int indexOfModifiedDate     = dataReader.GetOrdinal("ModifiedDate");

                                int rowCount = 0;


                                while (dataReader.Read() && rowCount < 1000 /*easy replace*/)
                                {
                                    if (rowCount > 0 && (rowCount % 100) == 0)
                                    {
                                        Console.WriteLine("AdventureWorks2008R2:Person:BusinessEntity: {0}", rowCount);
                                    }

                                    if (rowCount > 0 && (rowCount % 1000) == 0)
                                    {
                                        Console.WriteLine("Comitting...");
                                        client.Transaction.Commit();
                                        client.Transaction.Enlist();
                                    }

                                    try
                                    {
                                        client.Document.Create("AdventureWorks2008R2:Person:BusinessEntity", new Models.Person_BusinessEntity
                                        {
                                            BusinessEntityID = dataReader.GetInt32(indexOfBusinessEntityID),
                                            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();
                }
            }
        }
コード例 #8
0
        public void Export_Purchasing_PurchaseOrderHeader()
        {
            using (var client = new MammutClient("https://*****:*****@ssWord!"))
            {
                //if(client.Schema.Exists("AdventureWorks2008R2:Purchasing:PurchaseOrderHeader"))
                //{
                //	return;
                //}

                client.Transaction.Enlist();

                client.Schema.CreateAll("AdventureWorks2008R2:Purchasing:PurchaseOrderHeader");

                using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2008R2;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 < 1000 /*easy replace*/)
                                {
                                    if (rowCount > 0 && (rowCount % 100) == 0)
                                    {
                                        Console.WriteLine("AdventureWorks2008R2:Purchasing:PurchaseOrderHeader: {0}", rowCount);
                                    }

                                    if (rowCount > 0 && (rowCount % 1000) == 0)
                                    {
                                        Console.WriteLine("Comitting...");
                                        client.Transaction.Commit();
                                        client.Transaction.Enlist();
                                    }

                                    try
                                    {
                                        client.Document.Create("AdventureWorks2008R2:Purchasing:PurchaseOrderHeader", 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();
                }
            }
        }
コード例 #9
0
        public void Export_Production_TransactionHistory()
        {
            using (var client = new MammutClient("https://*****:*****@ssWord!"))
            {
                //if(client.Schema.Exists("AdventureWorks2008R2:Production:TransactionHistory"))
                //{
                //	return;
                //}

                client.Transaction.Enlist();

                client.Schema.CreateAll("AdventureWorks2008R2:Production:TransactionHistory");

                using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2008R2;Trusted_Connection=True;"))
                {
                    connection.Open();

                    try
                    {
                        using (SqlCommand command = new SqlCommand("SELECT * FROM Production.TransactionHistory", connection))
                        {
                            command.CommandTimeout = 10000;
                            command.CommandType    = System.Data.CommandType.Text;

                            using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                            {
                                int indexOfTransactionID        = dataReader.GetOrdinal("TransactionID");
                                int indexOfProductID            = dataReader.GetOrdinal("ProductID");
                                int indexOfReferenceOrderID     = dataReader.GetOrdinal("ReferenceOrderID");
                                int indexOfReferenceOrderLineID = dataReader.GetOrdinal("ReferenceOrderLineID");
                                int indexOfTransactionDate      = dataReader.GetOrdinal("TransactionDate");
                                int indexOfTransactionType      = dataReader.GetOrdinal("TransactionType");
                                int indexOfQuantity             = dataReader.GetOrdinal("Quantity");
                                int indexOfActualCost           = dataReader.GetOrdinal("ActualCost");
                                int indexOfModifiedDate         = dataReader.GetOrdinal("ModifiedDate");

                                int rowCount = 0;


                                while (dataReader.Read() && rowCount < 1000 /*easy replace*/)
                                {
                                    if (rowCount > 0 && (rowCount % 100) == 0)
                                    {
                                        Console.WriteLine("AdventureWorks2008R2:Production:TransactionHistory: {0}", rowCount);
                                    }

                                    if (rowCount > 0 && (rowCount % 1000) == 0)
                                    {
                                        Console.WriteLine("Comitting...");
                                        client.Transaction.Commit();
                                        client.Transaction.Enlist();
                                    }

                                    try
                                    {
                                        client.Document.Create("AdventureWorks2008R2:Production:TransactionHistory", new Models.Production_TransactionHistory
                                        {
                                            TransactionID        = dataReader.GetInt32(indexOfTransactionID),
                                            ProductID            = dataReader.GetInt32(indexOfProductID),
                                            ReferenceOrderID     = dataReader.GetInt32(indexOfReferenceOrderID),
                                            ReferenceOrderLineID = dataReader.GetInt32(indexOfReferenceOrderLineID),
                                            TransactionDate      = dataReader.GetDateTime(indexOfTransactionDate),
                                            TransactionType      = dataReader.GetString(indexOfTransactionType),
                                            Quantity             = dataReader.GetInt32(indexOfQuantity),
                                            ActualCost           = dataReader.GetDecimal(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();
                }
            }
        }
コード例 #10
0
        public void Export_Person_Person()
        {
            using (var client = new MammutClient("https://*****:*****@ssWord!"))
            {
                //if(client.Schema.Exists("AdventureWorks2008R2:Person:Person"))
                //{
                //	return;
                //}

                client.Transaction.Enlist();

                client.Schema.CreateAll("AdventureWorks2008R2:Person:Person");

                using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2008R2;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 < 1000 /*easy replace*/)
                                {
                                    if (rowCount > 0 && (rowCount % 100) == 0)
                                    {
                                        Console.WriteLine("AdventureWorks2008R2:Person:Person: {0}", rowCount);
                                    }

                                    if (rowCount > 0 && (rowCount % 1000) == 0)
                                    {
                                        Console.WriteLine("Comitting...");
                                        client.Transaction.Commit();
                                        client.Transaction.Enlist();
                                    }

                                    try
                                    {
                                        client.Document.Create("AdventureWorks2008R2:Person:Person", 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();
                }
            }
        }
コード例 #11
0
ファイル: DocumentClient.cs プロジェクト: NTDLS/MammutDB
 public DocumentClient(MammutClient client)
     : base(client)
 {
     _client = client;
 }
コード例 #12
0
ファイル: MammutAPI.cs プロジェクト: NTDLS/MammutDB
 public MammutAPI(MammutClient client)
 {
     this._MammutClient = client;
 }
コード例 #13
0
        public void Export_Production_Document()
        {
            using (var client = new MammutClient("https://*****:*****@ssWord!"))
            {
                //if(client.Schema.Exists("AdventureWorks2008R2:Production:Document"))
                //{
                //	return;
                //}

                client.Transaction.Enlist();

                client.Schema.CreateAll("AdventureWorks2008R2:Production:Document");

                using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2008R2;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 indexOfDocumentNode    = dataReader.GetOrdinal("DocumentNode");
                                int indexOfDocumentLevel   = dataReader.GetOrdinal("DocumentLevel");
                                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 < 1000 /*easy replace*/)
                                {
                                    if (rowCount > 0 && (rowCount % 100) == 0)
                                    {
                                        Console.WriteLine("AdventureWorks2008R2:Production:Document: {0}", rowCount);
                                    }

                                    if (rowCount > 0 && (rowCount % 1000) == 0)
                                    {
                                        Console.WriteLine("Comitting...");
                                        client.Transaction.Commit();
                                        client.Transaction.Enlist();
                                    }

                                    try
                                    {
                                        client.Document.Create("AdventureWorks2008R2:Production:Document", new Models.Production_Document
                                        {
                                            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();
                }
            }
        }
コード例 #14
0
 public QueryClient(MammutClient client)
     : base(client)
 {
     _client = client;
 }
コード例 #15
0
 public SecurityClient(MammutClient client)
     : base(client)
 {
     _client = client;
 }
コード例 #16
0
        public void Export_Production_Product()
        {
            using (var client = new MammutClient("https://*****:*****@ssWord!"))
            {
                //if(client.Schema.Exists("AdventureWorks2008R2:Production:Product"))
                //{
                //	return;
                //}

                client.Transaction.Enlist();

                client.Schema.CreateAll("AdventureWorks2008R2:Production:Product");

                using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2008R2;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 < 1000 /*easy replace*/)
                                {
                                    if (rowCount > 0 && (rowCount % 100) == 0)
                                    {
                                        Console.WriteLine("AdventureWorks2008R2:Production:Product: {0}", rowCount);
                                    }

                                    if (rowCount > 0 && (rowCount % 1000) == 0)
                                    {
                                        Console.WriteLine("Comitting...");
                                        client.Transaction.Commit();
                                        client.Transaction.Enlist();
                                    }

                                    try
                                    {
                                        client.Document.Create("AdventureWorks2008R2:Production:Product", 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();
                }
            }
        }
コード例 #17
0
        public void Export_Sales_SalesOrderDetail()
        {
            using (var client = new MammutClient("https://*****:*****@ssWord!"))
            {
                //if(client.Schema.Exists("AdventureWorks2008R2:Sales:SalesOrderDetail"))
                //{
                //	return;
                //}

                client.Transaction.Enlist();

                client.Schema.CreateAll("AdventureWorks2008R2:Sales:SalesOrderDetail");

                using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2008R2;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 < 1000 /*easy replace*/)
                                {
                                    if (rowCount > 0 && (rowCount % 100) == 0)
                                    {
                                        Console.WriteLine("AdventureWorks2008R2:Sales:SalesOrderDetail: {0}", rowCount);
                                    }

                                    if (rowCount > 0 && (rowCount % 1000) == 0)
                                    {
                                        Console.WriteLine("Comitting...");
                                        client.Transaction.Commit();
                                        client.Transaction.Enlist();
                                    }

                                    try
                                    {
                                        client.Document.Create("AdventureWorks2008R2:Sales:SalesOrderDetail", 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();
                }
            }
        }
コード例 #18
0
        public void Export_dbo_ErrorLog()
        {
            using (var client = new MammutClient("https://*****:*****@ssWord!"))
            {
                //if(client.Schema.Exists("AdventureWorks2008R2:dbo:ErrorLog"))
                //{
                //	return;
                //}

                client.Transaction.Enlist();

                client.Schema.CreateAll("AdventureWorks2008R2:dbo:ErrorLog");

                using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2008R2;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 < 1000 /*easy replace*/)
                                {
                                    if (rowCount > 0 && (rowCount % 100) == 0)
                                    {
                                        Console.WriteLine("AdventureWorks2008R2:dbo:ErrorLog: {0}", rowCount);
                                    }

                                    if (rowCount > 0 && (rowCount % 1000) == 0)
                                    {
                                        Console.WriteLine("Comitting...");
                                        client.Transaction.Commit();
                                        client.Transaction.Enlist();
                                    }

                                    try
                                    {
                                        client.Document.Create("AdventureWorks2008R2:dbo:ErrorLog", 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();
                }
            }
        }
コード例 #19
0
        public void Export_HumanResources_Employee()
        {
            using (var client = new MammutClient("https://*****:*****@ssWord!"))
            {
                //if(client.Schema.Exists("AdventureWorks2008R2:HumanResources:Employee"))
                //{
                //	return;
                //}

                client.Transaction.Enlist();

                client.Schema.CreateAll("AdventureWorks2008R2:HumanResources:Employee");

                using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2008R2;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 indexOfOrganizationNode  = dataReader.GetOrdinal("OrganizationNode");
                                int indexOfOrganizationLevel = dataReader.GetOrdinal("OrganizationLevel");
                                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 < 1000 /*easy replace*/)
                                {
                                    if (rowCount > 0 && (rowCount % 100) == 0)
                                    {
                                        Console.WriteLine("AdventureWorks2008R2:HumanResources:Employee: {0}", rowCount);
                                    }

                                    if (rowCount > 0 && (rowCount % 1000) == 0)
                                    {
                                        Console.WriteLine("Comitting...");
                                        client.Transaction.Commit();
                                        client.Transaction.Enlist();
                                    }

                                    try
                                    {
                                        client.Document.Create("AdventureWorks2008R2:HumanResources:Employee", new Models.HumanResources_Employee
                                        {
                                            BusinessEntityID  = dataReader.GetInt32(indexOfBusinessEntityID),
                                            NationalIDNumber  = dataReader.GetString(indexOfNationalIDNumber),
                                            LoginID           = dataReader.GetString(indexOfLoginID),
                                            OrganizationLevel = dataReader.GetNullableInt16(indexOfOrganizationLevel),
                                            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();
                }
            }
        }
コード例 #20
0
        public void Export_Sales_SpecialOffer()
        {
            using (var client = new MammutClient("https://*****:*****@ssWord!"))
            {
                //if(client.Schema.Exists("AdventureWorks2008R2:Sales:SpecialOffer"))
                //{
                //	return;
                //}

                client.Transaction.Enlist();

                client.Schema.CreateAll("AdventureWorks2008R2:Sales:SpecialOffer");

                using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2008R2;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 < 1000 /*easy replace*/)
                                {
                                    if (rowCount > 0 && (rowCount % 100) == 0)
                                    {
                                        Console.WriteLine("AdventureWorks2008R2:Sales:SpecialOffer: {0}", rowCount);
                                    }

                                    if (rowCount > 0 && (rowCount % 1000) == 0)
                                    {
                                        Console.WriteLine("Comitting...");
                                        client.Transaction.Commit();
                                        client.Transaction.Enlist();
                                    }

                                    try
                                    {
                                        client.Document.Create("AdventureWorks2008R2:Sales:SpecialOffer", 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();
                }
            }
        }
コード例 #21
0
        public void Export_Sales_SalesOrderHeader()
        {
            using (var client = new MammutClient("https://*****:*****@ssWord!"))
            {
                //if(client.Schema.Exists("AdventureWorks2008R2:Sales:SalesOrderHeader"))
                //{
                //	return;
                //}

                client.Transaction.Enlist();

                client.Schema.CreateAll("AdventureWorks2008R2:Sales:SalesOrderHeader");

                using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2008R2;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 < 1000 /*easy replace*/)
                                {
                                    if (rowCount > 0 && (rowCount % 100) == 0)
                                    {
                                        Console.WriteLine("AdventureWorks2008R2:Sales:SalesOrderHeader: {0}", rowCount);
                                    }

                                    if (rowCount > 0 && (rowCount % 1000) == 0)
                                    {
                                        Console.WriteLine("Comitting...");
                                        client.Transaction.Commit();
                                        client.Transaction.Enlist();
                                    }

                                    try
                                    {
                                        client.Document.Create("AdventureWorks2008R2:Sales:SalesOrderHeader", 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();
                }
            }
        }
コード例 #22
0
 public SchemaClient(MammutClient client)
     : base(client)
 {
     _client = client;
 }
コード例 #23
0
        public void Export_Production_WorkOrder()
        {
            using (var client = new MammutClient("https://*****:*****@ssWord!"))
            {
                //if(client.Schema.Exists("AdventureWorks2008R2:Production:WorkOrder"))
                //{
                //	return;
                //}

                client.Transaction.Enlist();

                client.Schema.CreateAll("AdventureWorks2008R2:Production:WorkOrder");

                using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2008R2;Trusted_Connection=True;"))
                {
                    connection.Open();

                    try
                    {
                        using (SqlCommand command = new SqlCommand("SELECT * FROM Production.WorkOrder", 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 indexOfOrderQty      = dataReader.GetOrdinal("OrderQty");
                                int indexOfStockedQty    = dataReader.GetOrdinal("StockedQty");
                                int indexOfScrappedQty   = dataReader.GetOrdinal("ScrappedQty");
                                int indexOfStartDate     = dataReader.GetOrdinal("StartDate");
                                int indexOfEndDate       = dataReader.GetOrdinal("EndDate");
                                int indexOfDueDate       = dataReader.GetOrdinal("DueDate");
                                int indexOfScrapReasonID = dataReader.GetOrdinal("ScrapReasonID");
                                int indexOfModifiedDate  = dataReader.GetOrdinal("ModifiedDate");

                                int rowCount = 0;


                                while (dataReader.Read() && rowCount < 1000 /*easy replace*/)
                                {
                                    if (rowCount > 0 && (rowCount % 100) == 0)
                                    {
                                        Console.WriteLine("AdventureWorks2008R2:Production:WorkOrder: {0}", rowCount);
                                    }

                                    if (rowCount > 0 && (rowCount % 1000) == 0)
                                    {
                                        Console.WriteLine("Comitting...");
                                        client.Transaction.Commit();
                                        client.Transaction.Enlist();
                                    }

                                    try
                                    {
                                        client.Document.Create("AdventureWorks2008R2:Production:WorkOrder", new Models.Production_WorkOrder
                                        {
                                            WorkOrderID   = dataReader.GetInt32(indexOfWorkOrderID),
                                            ProductID     = dataReader.GetInt32(indexOfProductID),
                                            OrderQty      = dataReader.GetInt32(indexOfOrderQty),
                                            StockedQty    = dataReader.GetInt32(indexOfStockedQty),
                                            ScrappedQty   = dataReader.GetInt16(indexOfScrappedQty),
                                            StartDate     = dataReader.GetDateTime(indexOfStartDate),
                                            EndDate       = dataReader.GetNullableDateTime(indexOfEndDate),
                                            DueDate       = dataReader.GetDateTime(indexOfDueDate),
                                            ScrapReasonID = dataReader.GetNullableInt16(indexOfScrapReasonID),
                                            ModifiedDate  = dataReader.GetDateTime(indexOfModifiedDate),
                                        });
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex.Message);
                                    }

                                    rowCount++;
                                }
                            }
                        }
                        connection.Close();
                    }
                    catch
                    {
                        //TODO: add error handling/logging
                        throw;
                    }

                    client.Transaction.Commit();
                }
            }
        }
コード例 #24
0
        public void Export_Purchasing_Vendor()
        {
            using (var client = new MammutClient("https://*****:*****@ssWord!"))
            {
                //if(client.Schema.Exists("AdventureWorks2008R2:Purchasing:Vendor"))
                //{
                //	return;
                //}

                client.Transaction.Enlist();

                client.Schema.CreateAll("AdventureWorks2008R2:Purchasing:Vendor");

                using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2008R2;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 < 1000 /*easy replace*/)
                                {
                                    if (rowCount > 0 && (rowCount % 100) == 0)
                                    {
                                        Console.WriteLine("AdventureWorks2008R2:Purchasing:Vendor: {0}", rowCount);
                                    }

                                    if (rowCount > 0 && (rowCount % 1000) == 0)
                                    {
                                        Console.WriteLine("Comitting...");
                                        client.Transaction.Commit();
                                        client.Transaction.Enlist();
                                    }

                                    try
                                    {
                                        client.Document.Create("AdventureWorks2008R2:Purchasing:Vendor", 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();
                }
            }
        }
コード例 #25
0
        public void Export_Production_ProductReview()
        {
            using (var client = new MammutClient("https://*****:*****@ssWord!"))
            {
                //if(client.Schema.Exists("AdventureWorks2008R2:Production:ProductReview"))
                //{
                //	return;
                //}

                client.Transaction.Enlist();

                client.Schema.CreateAll("AdventureWorks2008R2:Production:ProductReview");

                using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2008R2;Trusted_Connection=True;"))
                {
                    connection.Open();

                    try
                    {
                        using (SqlCommand command = new SqlCommand("SELECT * FROM Production.ProductReview", connection))
                        {
                            command.CommandTimeout = 10000;
                            command.CommandType    = System.Data.CommandType.Text;

                            using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                            {
                                int indexOfProductReviewID = dataReader.GetOrdinal("ProductReviewID");
                                int indexOfProductID       = dataReader.GetOrdinal("ProductID");
                                int indexOfReviewerName    = dataReader.GetOrdinal("ReviewerName");
                                int indexOfReviewDate      = dataReader.GetOrdinal("ReviewDate");
                                int indexOfEmailAddress    = dataReader.GetOrdinal("EmailAddress");
                                int indexOfRating          = dataReader.GetOrdinal("Rating");
                                int indexOfComments        = dataReader.GetOrdinal("Comments");
                                int indexOfModifiedDate    = dataReader.GetOrdinal("ModifiedDate");

                                int rowCount = 0;


                                while (dataReader.Read() && rowCount < 1000 /*easy replace*/)
                                {
                                    if (rowCount > 0 && (rowCount % 100) == 0)
                                    {
                                        Console.WriteLine("AdventureWorks2008R2:Production:ProductReview: {0}", rowCount);
                                    }

                                    if (rowCount > 0 && (rowCount % 1000) == 0)
                                    {
                                        Console.WriteLine("Comitting...");
                                        client.Transaction.Commit();
                                        client.Transaction.Enlist();
                                    }

                                    try
                                    {
                                        client.Document.Create("AdventureWorks2008R2:Production:ProductReview", new Models.Production_ProductReview
                                        {
                                            ProductReviewID = dataReader.GetInt32(indexOfProductReviewID),
                                            ProductID       = dataReader.GetInt32(indexOfProductID),
                                            ReviewerName    = dataReader.GetString(indexOfReviewerName),
                                            ReviewDate      = dataReader.GetDateTime(indexOfReviewDate),
                                            EmailAddress    = dataReader.GetString(indexOfEmailAddress),
                                            Rating          = dataReader.GetInt32(indexOfRating),
                                            Comments        = dataReader.GetNullableString(indexOfComments),
                                            ModifiedDate    = dataReader.GetDateTime(indexOfModifiedDate),
                                        });
                                    }
                                    catch (Exception ex)
                                    {
                                        Console.WriteLine(ex.Message);
                                    }

                                    rowCount++;
                                }
                            }
                        }
                        connection.Close();
                    }
                    catch
                    {
                        //TODO: add error handling/logging
                        throw;
                    }

                    client.Transaction.Commit();
                }
            }
        }
コード例 #26
0
        public void Export_HumanResources_Shift()
        {
            using (var client = new MammutClient("https://*****:*****@ssWord!"))
            {
                //if(client.Schema.Exists("AdventureWorks2008R2:HumanResources:Shift"))
                //{
                //	return;
                //}

                client.Transaction.Enlist();

                client.Schema.CreateAll("AdventureWorks2008R2:HumanResources:Shift");

                using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2008R2;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 < 1000 /*easy replace*/)
                                {
                                    if (rowCount > 0 && (rowCount % 100) == 0)
                                    {
                                        Console.WriteLine("AdventureWorks2008R2:HumanResources:Shift: {0}", rowCount);
                                    }

                                    if (rowCount > 0 && (rowCount % 1000) == 0)
                                    {
                                        Console.WriteLine("Comitting...");
                                        client.Transaction.Commit();
                                        client.Transaction.Enlist();
                                    }

                                    try
                                    {
                                        client.Document.Create("AdventureWorks2008R2:HumanResources:Shift", 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();
                }
            }
        }
コード例 #27
0
        public void Export_Purchasing_ProductVendor()
        {
            using (var client = new MammutClient("https://*****:*****@ssWord!"))
            {
                //if(client.Schema.Exists("AdventureWorks2008R2:Purchasing:ProductVendor"))
                //{
                //	return;
                //}

                client.Transaction.Enlist();

                client.Schema.CreateAll("AdventureWorks2008R2:Purchasing:ProductVendor");

                using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2008R2;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 < 1000 /*easy replace*/)
                                {
                                    if (rowCount > 0 && (rowCount % 100) == 0)
                                    {
                                        Console.WriteLine("AdventureWorks2008R2:Purchasing:ProductVendor: {0}", rowCount);
                                    }

                                    if (rowCount > 0 && (rowCount % 1000) == 0)
                                    {
                                        Console.WriteLine("Comitting...");
                                        client.Transaction.Commit();
                                        client.Transaction.Enlist();
                                    }

                                    try
                                    {
                                        client.Document.Create("AdventureWorks2008R2:Purchasing:ProductVendor", 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();
                }
            }
        }