Пример #1
0
        public void PopulateSchemas(LeafSQLClient client, LSTreeNode node, bool populateOneLevelDeeper)
        {
            string SchemaName = GetFullSchemaNameFromNode(node);

            var schemas = client.Schema.List(SchemaName);

            if (node.Nodes.OfType <TreeNode>().FirstOrDefault(o => o.Text == "Indexes") == null)
            {
                LSTreeNode parentIndexesNode = new LSTreeNode(Types.TreeNodeType.Indexes, "Indexes", "Indexes");
                node.Nodes.Add(parentIndexesNode);
                PopulateSchemaIndexes(client, parentIndexesNode);
            }

            foreach (var schema in schemas)
            {
                LSTreeNode SchemaNode  = new LSTreeNode(Types.TreeNodeType.Schema, schema.Name, schema.Name);
                LSTreeNode indexesNode = new LSTreeNode(Types.TreeNodeType.Indexes, "Indexes", "Indexes");

                SchemaNode.Nodes.Add(indexesNode);
                node.Nodes.Add(SchemaNode);

                PopulateSchemaIndexes(client, indexesNode);
            }

            if (populateOneLevelDeeper)
            {
                foreach (LSTreeNode subNode in node.Nodes)
                {
                    if (subNode.Type == Types.TreeNodeType.Schema)
                    {
                        PopulateSchemas(client, subNode, false);
                    }
                }
            }
        }
Пример #2
0
        public void PopulateServerExplorer(LeafSQLClient client)
        {
            treeView.Nodes.Clear();
            treeView.ImageList = imageListTreeView;

            var serverSettings = client.Server.Settings.Get();
            var serverVersion  = client.Server.Settings.GetVersion();

            ServerNode = new LSTreeNode(Types.TreeNodeType.Server, $"{serverSettings.Name} ({serverVersion.Version})", serverSettings.Name);

            SchemaNode = new LSTreeNode(Types.TreeNodeType.Schemas, "Schemas", "Schemas");
            SchemaNode.Nodes.Add(new LSTreeNode(Types.TreeNodeType.Schema, "<root>", ":"));
            SchemaNode.Expand();
            ServerNode.Nodes.Add(SchemaNode);
            SchemaNode.Nodes[0].Expand();
            PopulateSchemas(client, (LSTreeNode)SchemaNode.Nodes[0], true);

            LoginsNode          = new LSTreeNode(Types.TreeNodeType.Logins, "Logins");
            LoginsNode.ImageKey = "Logins";
            LoginsNode.Expand();
            ServerNode.Nodes.Add(LoginsNode);
            PopulateLogins(client);

            treeView.Nodes.Add(ServerNode);
            ServerNode.Expand();
        }
Пример #3
0
 public Server(LeafSQLClient client)
     : base(client)
 {
     this.client   = client;
     this.Settings = new Settings(client);
     this.State    = new State(client);
 }
Пример #4
0
        public BrowseDocuments(LeafSQLClient client, string namespaceName)
        {
            InitializeComponent();

            this.client        = client;
            this.namespaceName = namespaceName;

            PopulatePage();
        }
Пример #5
0
        public void PopulateLogins(LeafSQLClient client)
        {
            LoginsNode.Nodes.Clear();

            var logins = client.Security.GetLogins();

            foreach (var login in logins.OrderBy(o => o.Name))
            {
                LoginsNode.Nodes.Add(new LSTreeNode(Types.TreeNodeType.Login, login.Name, login.Id));
            }
        }
Пример #6
0
        public void PopulateSchemaIndexes(LeafSQLClient client, LSTreeNode node)
        {
            node.Nodes.Clear();

            string SchemaName = GetFullSchemaNameFromNode(node);

            var indexes = client.Schema.Indexes.List(SchemaName);

            foreach (Index index in indexes.OrderBy(o => o.Name))
            {
                var indexNode = new LSTreeNode(Types.TreeNodeType.Index, index.Name);

                foreach (IndexAttribute attribute in index.Attributes)
                {
                    indexNode.Nodes.Add(new LSTreeNode(Types.TreeNodeType.IndexAttribute, attribute.Name));
                }

                node.Nodes.Add(indexNode);
            }
        }
Пример #7
0
        private void FormMain_Shown(object sender, EventArgs e)
        {
            using (var formLogin = new FormLogin())
            {
                if (formLogin.ShowDialog() == DialogResult.OK)
                {
                    client = new LeafSQLClient(formLogin.Address, formLogin.Username, formLogin.Password);
                }
                else
                {
                    this.DialogResult = DialogResult.Cancel;
                    this.Close();
                    return;
                }
            }

            treeManager.PopulateServerExplorer(client);

            tabManager.AddNewTab();

            isInitializing = false;
        }
Пример #8
0
        private void buttonLogin_Click(object sender, EventArgs e)
        {
            try
            {
                LeafSQLClient client = new LeafSQLClient(textBoxAddress.Text);

                var loginToken = client.Login(textBoxUsername.Text, textBoxPassword.Text);
                if (loginToken.IsValid == false)
                {
                    MessageBox.Show("Login failed.");
                    return;
                }

                client.Logout();

                this.DialogResult = DialogResult.OK;
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message);
            }
        }
Пример #9
0
 public State(LeafSQLClient client)
     : base(client)
 {
     this.client = client;
 }
Пример #10
0
        public void Export_Production_Product()
        {
            LeafSQLClient client = new LeafSQLClient("http://localhost:6858/", "admin", "");

            if (client.Schema.Exists("AdventureWorks2012:Production:Product"))
            {
                return;
            }

            client.Transaction.Begin();

            client.Schema.Create("AdventureWorks2012:Production:Product");

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

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

                        using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                        {
                            int indexOfProductID             = dataReader.GetOrdinal("ProductID");
                            int indexOfName                  = dataReader.GetOrdinal("Name");
                            int indexOfProductNumber         = dataReader.GetOrdinal("ProductNumber");
                            int indexOfMakeFlag              = dataReader.GetOrdinal("MakeFlag");
                            int indexOfFinishedGoodsFlag     = dataReader.GetOrdinal("FinishedGoodsFlag");
                            int indexOfColor                 = dataReader.GetOrdinal("Color");
                            int indexOfSafetyStockLevel      = dataReader.GetOrdinal("SafetyStockLevel");
                            int indexOfReorderPoint          = dataReader.GetOrdinal("ReorderPoint");
                            int indexOfStandardCost          = dataReader.GetOrdinal("StandardCost");
                            int indexOfListPrice             = dataReader.GetOrdinal("ListPrice");
                            int indexOfSize                  = dataReader.GetOrdinal("Size");
                            int indexOfSizeUnitMeasureCode   = dataReader.GetOrdinal("SizeUnitMeasureCode");
                            int indexOfWeightUnitMeasureCode = dataReader.GetOrdinal("WeightUnitMeasureCode");
                            int indexOfWeight                = dataReader.GetOrdinal("Weight");
                            int indexOfDaysToManufacture     = dataReader.GetOrdinal("DaysToManufacture");
                            int indexOfProductLine           = dataReader.GetOrdinal("ProductLine");
                            int indexOfClass                 = dataReader.GetOrdinal("Class");
                            int indexOfStyle                 = dataReader.GetOrdinal("Style");
                            int indexOfProductSubcategoryID  = dataReader.GetOrdinal("ProductSubcategoryID");
                            int indexOfProductModelID        = dataReader.GetOrdinal("ProductModelID");
                            int indexOfSellStartDate         = dataReader.GetOrdinal("SellStartDate");
                            int indexOfSellEndDate           = dataReader.GetOrdinal("SellEndDate");
                            int indexOfDiscontinuedDate      = dataReader.GetOrdinal("DiscontinuedDate");
                            int indexOfrowguid               = dataReader.GetOrdinal("rowguid");
                            int indexOfModifiedDate          = dataReader.GetOrdinal("ModifiedDate");

                            int rowCount = 0;


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

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

                                try
                                {
                                    client.Document.Store("AdventureWorks2012:Production:Product", new Document(new Models.Production_Product
                                    {
                                        ProductID             = dataReader.GetInt32(indexOfProductID),
                                        Name                  = dataReader.GetString(indexOfName),
                                        ProductNumber         = dataReader.GetString(indexOfProductNumber),
                                        MakeFlag              = dataReader.GetBoolean(indexOfMakeFlag),
                                        FinishedGoodsFlag     = dataReader.GetBoolean(indexOfFinishedGoodsFlag),
                                        Color                 = dataReader.GetNullableString(indexOfColor),
                                        SafetyStockLevel      = dataReader.GetInt16(indexOfSafetyStockLevel),
                                        ReorderPoint          = dataReader.GetInt16(indexOfReorderPoint),
                                        StandardCost          = dataReader.GetDecimal(indexOfStandardCost),
                                        ListPrice             = dataReader.GetDecimal(indexOfListPrice),
                                        Size                  = dataReader.GetNullableString(indexOfSize),
                                        SizeUnitMeasureCode   = dataReader.GetNullableString(indexOfSizeUnitMeasureCode),
                                        WeightUnitMeasureCode = dataReader.GetNullableString(indexOfWeightUnitMeasureCode),
                                        Weight                = dataReader.GetNullableDecimal(indexOfWeight),
                                        DaysToManufacture     = dataReader.GetInt32(indexOfDaysToManufacture),
                                        ProductLine           = dataReader.GetNullableString(indexOfProductLine),
                                        Class                 = dataReader.GetNullableString(indexOfClass),
                                        Style                 = dataReader.GetNullableString(indexOfStyle),
                                        ProductSubcategoryID  = dataReader.GetNullableInt32(indexOfProductSubcategoryID),
                                        ProductModelID        = dataReader.GetNullableInt32(indexOfProductModelID),
                                        SellStartDate         = dataReader.GetDateTime(indexOfSellStartDate),
                                        SellEndDate           = dataReader.GetNullableDateTime(indexOfSellEndDate),
                                        DiscontinuedDate      = dataReader.GetNullableDateTime(indexOfDiscontinuedDate),
                                        rowguid               = dataReader.GetGuid(indexOfrowguid),
                                        ModifiedDate          = dataReader.GetDateTime(indexOfModifiedDate),
                                    }));
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                }

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

                client.Transaction.Commit();
            }
        }
        public void Export_Sales_SalesOrderHeaderSalesReason()
        {
            LeafSQLClient client = new LeafSQLClient("http://localhost:6858/", "admin", "");

            if (client.Schema.Exists("AdventureWorks2012:Sales:SalesOrderHeaderSalesReason"))
            {
                return;
            }

            client.Transaction.Begin();

            client.Schema.Create("AdventureWorks2012:Sales:SalesOrderHeaderSalesReason");

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

                try
                {
                    using (SqlCommand command = new SqlCommand("SELECT * FROM Sales.SalesOrderHeaderSalesReason", 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 indexOfSalesReasonID = dataReader.GetOrdinal("SalesReasonID");
                            int indexOfModifiedDate  = dataReader.GetOrdinal("ModifiedDate");

                            int rowCount = 0;


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

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

                                try
                                {
                                    client.Document.Store("AdventureWorks2012:Sales:SalesOrderHeaderSalesReason", new Document(new Models.Sales_SalesOrderHeaderSalesReason
                                    {
                                        SalesOrderID  = dataReader.GetInt32(indexOfSalesOrderID),
                                        SalesReasonID = dataReader.GetInt32(indexOfSalesReasonID),
                                        ModifiedDate  = dataReader.GetDateTime(indexOfModifiedDate),
                                    }));
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                }

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

                client.Transaction.Commit();
            }
        }
Пример #12
0
 public Document(LeafSQLClient client)
     : base(client)
 {
     this.client = client;
 }
        public void Export_Purchasing_PurchaseOrderDetail()
        {
            LeafSQLClient client = new LeafSQLClient("http://localhost:6858/", "admin", "");

            if (client.Schema.Exists("AdventureWorks2012:Purchasing:PurchaseOrderDetail"))
            {
                return;
            }

            client.Transaction.Begin();

            client.Schema.Create("AdventureWorks2012:Purchasing:PurchaseOrderDetail");

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

                try
                {
                    using (SqlCommand command = new SqlCommand("SELECT * FROM Purchasing.PurchaseOrderDetail", 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 indexOfPurchaseOrderDetailID = dataReader.GetOrdinal("PurchaseOrderDetailID");
                            int indexOfDueDate      = dataReader.GetOrdinal("DueDate");
                            int indexOfOrderQty     = dataReader.GetOrdinal("OrderQty");
                            int indexOfProductID    = dataReader.GetOrdinal("ProductID");
                            int indexOfUnitPrice    = dataReader.GetOrdinal("UnitPrice");
                            int indexOfLineTotal    = dataReader.GetOrdinal("LineTotal");
                            int indexOfReceivedQty  = dataReader.GetOrdinal("ReceivedQty");
                            int indexOfRejectedQty  = dataReader.GetOrdinal("RejectedQty");
                            int indexOfStockedQty   = dataReader.GetOrdinal("StockedQty");
                            int indexOfModifiedDate = dataReader.GetOrdinal("ModifiedDate");

                            int rowCount = 0;


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

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

                                try
                                {
                                    client.Document.Store("AdventureWorks2012:Purchasing:PurchaseOrderDetail", new Document(new Models.Purchasing_PurchaseOrderDetail
                                    {
                                        PurchaseOrderID       = dataReader.GetInt32(indexOfPurchaseOrderID),
                                        PurchaseOrderDetailID = dataReader.GetInt32(indexOfPurchaseOrderDetailID),
                                        DueDate      = dataReader.GetDateTime(indexOfDueDate),
                                        OrderQty     = dataReader.GetInt16(indexOfOrderQty),
                                        ProductID    = dataReader.GetInt32(indexOfProductID),
                                        UnitPrice    = dataReader.GetDecimal(indexOfUnitPrice),
                                        LineTotal    = dataReader.GetDecimal(indexOfLineTotal),
                                        ReceivedQty  = dataReader.GetDecimal(indexOfReceivedQty),
                                        RejectedQty  = dataReader.GetDecimal(indexOfRejectedQty),
                                        StockedQty   = dataReader.GetDecimal(indexOfStockedQty),
                                        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 void Export_Production_Document()
        {
            LeafSQLClient client = new LeafSQLClient("http://localhost:6858/", "admin", "admin");

            if (client.Schema.Exists("AdventureWorks2012:Production:Document").Result)
            {
                return;
            }

            client.Transaction.Begin();

            client.Schema.Create("AdventureWorks2012:Production:Document").Wait();

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

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

                        using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                        {
                            int 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++ < 10000*/)
                            {
                                if (rowCount > 0 && (rowCount % 100) == 0)
                                {
                                    Console.WriteLine("AdventureWorks2012:Production:Document: {0}", rowCount);
                                }

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

                                try
                                {
                                    client.Document.Store("AdventureWorks2012:Production:Document", new Document(new Models.Production_Document
                                    {
                                        DocumentNode    = dataReader.GetHierarchyId(indexOfDocumentNode),
                                        DocumentLevel   = dataReader.GetNullableInt16(indexOfDocumentLevel),
                                        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),
                                    })).Wait();
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                }

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

                client.Transaction.Commit();
            }
        }
        public void Export_Production_TransactionHistoryArchive()
        {
            LeafSQLClient client = new LeafSQLClient("http://localhost:6858/", "admin", "");

            if (client.Schema.Exists("AdventureWorks2012:Production:TransactionHistoryArchive"))
            {
                return;
            }

            client.Transaction.Begin();

            client.Schema.Create("AdventureWorks2012:Production:TransactionHistoryArchive");

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

                try
                {
                    using (SqlCommand command = new SqlCommand("SELECT * FROM Production.TransactionHistoryArchive", 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("AdventureWorks2012:Production:TransactionHistoryArchive: {0}", rowCount);
                                }

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

                                try
                                {
                                    client.Document.Store("AdventureWorks2012:Production:TransactionHistoryArchive", new Document(new Models.Production_TransactionHistoryArchive
                                    {
                                        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();
            }
        }
        public void Export_Production_WorkOrderRouting()
        {
            LeafSQLClient client = new LeafSQLClient("http://localhost:6858/", "admin", "");

            if (client.Schema.Exists("AdventureWorks2012:Production:WorkOrderRouting"))
            {
                return;
            }

            client.Transaction.Begin();

            client.Schema.Create("AdventureWorks2012:Production:WorkOrderRouting");

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

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

                        using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                        {
                            int indexOfWorkOrderID        = dataReader.GetOrdinal("WorkOrderID");
                            int indexOfProductID          = dataReader.GetOrdinal("ProductID");
                            int indexOfOperationSequence  = dataReader.GetOrdinal("OperationSequence");
                            int indexOfLocationID         = dataReader.GetOrdinal("LocationID");
                            int indexOfScheduledStartDate = dataReader.GetOrdinal("ScheduledStartDate");
                            int indexOfScheduledEndDate   = dataReader.GetOrdinal("ScheduledEndDate");
                            int indexOfActualStartDate    = dataReader.GetOrdinal("ActualStartDate");
                            int indexOfActualEndDate      = dataReader.GetOrdinal("ActualEndDate");
                            int indexOfActualResourceHrs  = dataReader.GetOrdinal("ActualResourceHrs");
                            int indexOfPlannedCost        = dataReader.GetOrdinal("PlannedCost");
                            int indexOfActualCost         = dataReader.GetOrdinal("ActualCost");
                            int indexOfModifiedDate       = dataReader.GetOrdinal("ModifiedDate");

                            int rowCount = 0;


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

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

                                try
                                {
                                    client.Document.Store("AdventureWorks2012:Production:WorkOrderRouting", new Document(new Models.Production_WorkOrderRouting
                                    {
                                        WorkOrderID        = dataReader.GetInt32(indexOfWorkOrderID),
                                        ProductID          = dataReader.GetInt32(indexOfProductID),
                                        OperationSequence  = dataReader.GetInt16(indexOfOperationSequence),
                                        LocationID         = dataReader.GetInt16(indexOfLocationID),
                                        ScheduledStartDate = dataReader.GetDateTime(indexOfScheduledStartDate),
                                        ScheduledEndDate   = dataReader.GetDateTime(indexOfScheduledEndDate),
                                        ActualStartDate    = dataReader.GetNullableDateTime(indexOfActualStartDate),
                                        ActualEndDate      = dataReader.GetNullableDateTime(indexOfActualEndDate),
                                        ActualResourceHrs  = dataReader.GetNullableDecimal(indexOfActualResourceHrs),
                                        PlannedCost        = dataReader.GetDecimal(indexOfPlannedCost),
                                        ActualCost         = dataReader.GetNullableDecimal(indexOfActualCost),
                                        ModifiedDate       = dataReader.GetDateTime(indexOfModifiedDate),
                                    }));
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                }

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

                client.Transaction.Commit();
            }
        }
Пример #17
0
 public Schema(LeafSQLClient client)
     : base(client)
 {
     this.client  = client;
     this.Indexes = new Indexes(client);
 }
Пример #18
0
        public void Export_Person_StateProvince()
        {
            LeafSQLClient client = new LeafSQLClient("http://localhost:6858/", "admin", "");

            if (client.Schema.Exists("AdventureWorks2012:Person:StateProvince"))
            {
                return;
            }

            client.Transaction.Begin();

            client.Schema.Create("AdventureWorks2012:Person:StateProvince");

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

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

                        using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                        {
                            int indexOfStateProvinceID         = dataReader.GetOrdinal("StateProvinceID");
                            int indexOfStateProvinceCode       = dataReader.GetOrdinal("StateProvinceCode");
                            int indexOfCountryRegionCode       = dataReader.GetOrdinal("CountryRegionCode");
                            int indexOfIsOnlyStateProvinceFlag = dataReader.GetOrdinal("IsOnlyStateProvinceFlag");
                            int indexOfName         = dataReader.GetOrdinal("Name");
                            int indexOfTerritoryID  = dataReader.GetOrdinal("TerritoryID");
                            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("AdventureWorks2012:Person:StateProvince: {0}", rowCount);
                                }

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

                                try
                                {
                                    client.Document.Store("AdventureWorks2012:Person:StateProvince", new Document(new Models.Person_StateProvince
                                    {
                                        StateProvinceID         = dataReader.GetInt32(indexOfStateProvinceID),
                                        StateProvinceCode       = dataReader.GetString(indexOfStateProvinceCode),
                                        CountryRegionCode       = dataReader.GetString(indexOfCountryRegionCode),
                                        IsOnlyStateProvinceFlag = dataReader.GetBoolean(indexOfIsOnlyStateProvinceFlag),
                                        Name         = dataReader.GetString(indexOfName),
                                        TerritoryID  = dataReader.GetInt32(indexOfTerritoryID),
                                        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();
            }
        }
Пример #19
0
        public void Export_Purchasing_Vendor()
        {
            LeafSQLClient client = new LeafSQLClient("http://localhost:6858/", "admin", "");

            if (client.Schema.Exists("AdventureWorks2012:Purchasing:Vendor"))
            {
                return;
            }

            client.Transaction.Begin();

            client.Schema.Create("AdventureWorks2012:Purchasing:Vendor");

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

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

                        using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                        {
                            int indexOfBusinessEntityID        = dataReader.GetOrdinal("BusinessEntityID");
                            int indexOfAccountNumber           = dataReader.GetOrdinal("AccountNumber");
                            int indexOfName                    = dataReader.GetOrdinal("Name");
                            int indexOfCreditRating            = dataReader.GetOrdinal("CreditRating");
                            int indexOfPreferredVendorStatus   = dataReader.GetOrdinal("PreferredVendorStatus");
                            int indexOfActiveFlag              = dataReader.GetOrdinal("ActiveFlag");
                            int indexOfPurchasingWebServiceURL = dataReader.GetOrdinal("PurchasingWebServiceURL");
                            int indexOfModifiedDate            = dataReader.GetOrdinal("ModifiedDate");

                            int rowCount = 0;


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

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

                                try
                                {
                                    client.Document.Store("AdventureWorks2012:Purchasing:Vendor", new Document(new Models.Purchasing_Vendor
                                    {
                                        BusinessEntityID        = dataReader.GetInt32(indexOfBusinessEntityID),
                                        AccountNumber           = dataReader.GetString(indexOfAccountNumber),
                                        Name                    = dataReader.GetString(indexOfName),
                                        CreditRating            = dataReader.GetByte(indexOfCreditRating),
                                        PreferredVendorStatus   = dataReader.GetBoolean(indexOfPreferredVendorStatus),
                                        ActiveFlag              = dataReader.GetBoolean(indexOfActiveFlag),
                                        PurchasingWebServiceURL = dataReader.GetNullableString(indexOfPurchasingWebServiceURL),
                                        ModifiedDate            = dataReader.GetDateTime(indexOfModifiedDate),
                                    }));
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                }

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

                client.Transaction.Commit();
            }
        }
Пример #20
0
        public void Export_Sales_SalesOrderHeader()
        {
            LeafSQLClient client = new LeafSQLClient("http://localhost:6858/", "admin", "");

            if (client.Schema.Exists("AdventureWorks2012:Sales:SalesOrderHeader"))
            {
                return;
            }

            client.Transaction.Begin();

            client.Schema.Create("AdventureWorks2012:Sales:SalesOrderHeader");

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

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

                        using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                        {
                            int indexOfSalesOrderID           = dataReader.GetOrdinal("SalesOrderID");
                            int indexOfRevisionNumber         = dataReader.GetOrdinal("RevisionNumber");
                            int indexOfOrderDate              = dataReader.GetOrdinal("OrderDate");
                            int indexOfDueDate                = dataReader.GetOrdinal("DueDate");
                            int indexOfShipDate               = dataReader.GetOrdinal("ShipDate");
                            int indexOfStatus                 = dataReader.GetOrdinal("Status");
                            int indexOfOnlineOrderFlag        = dataReader.GetOrdinal("OnlineOrderFlag");
                            int indexOfSalesOrderNumber       = dataReader.GetOrdinal("SalesOrderNumber");
                            int indexOfPurchaseOrderNumber    = dataReader.GetOrdinal("PurchaseOrderNumber");
                            int indexOfAccountNumber          = dataReader.GetOrdinal("AccountNumber");
                            int indexOfCustomerID             = dataReader.GetOrdinal("CustomerID");
                            int indexOfSalesPersonID          = dataReader.GetOrdinal("SalesPersonID");
                            int indexOfTerritoryID            = dataReader.GetOrdinal("TerritoryID");
                            int indexOfBillToAddressID        = dataReader.GetOrdinal("BillToAddressID");
                            int indexOfShipToAddressID        = dataReader.GetOrdinal("ShipToAddressID");
                            int indexOfShipMethodID           = dataReader.GetOrdinal("ShipMethodID");
                            int indexOfCreditCardID           = dataReader.GetOrdinal("CreditCardID");
                            int indexOfCreditCardApprovalCode = dataReader.GetOrdinal("CreditCardApprovalCode");
                            int indexOfCurrencyRateID         = dataReader.GetOrdinal("CurrencyRateID");
                            int indexOfSubTotal               = dataReader.GetOrdinal("SubTotal");
                            int indexOfTaxAmt                 = dataReader.GetOrdinal("TaxAmt");
                            int indexOfFreight                = dataReader.GetOrdinal("Freight");
                            int indexOfTotalDue               = dataReader.GetOrdinal("TotalDue");
                            int indexOfComment                = dataReader.GetOrdinal("Comment");
                            int indexOfrowguid                = dataReader.GetOrdinal("rowguid");
                            int indexOfModifiedDate           = dataReader.GetOrdinal("ModifiedDate");

                            int rowCount = 0;


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

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

                                try
                                {
                                    client.Document.Store("AdventureWorks2012:Sales:SalesOrderHeader", new Document(new Models.Sales_SalesOrderHeader
                                    {
                                        SalesOrderID           = dataReader.GetInt32(indexOfSalesOrderID),
                                        RevisionNumber         = dataReader.GetByte(indexOfRevisionNumber),
                                        OrderDate              = dataReader.GetDateTime(indexOfOrderDate),
                                        DueDate                = dataReader.GetDateTime(indexOfDueDate),
                                        ShipDate               = dataReader.GetNullableDateTime(indexOfShipDate),
                                        Status                 = dataReader.GetByte(indexOfStatus),
                                        OnlineOrderFlag        = dataReader.GetBoolean(indexOfOnlineOrderFlag),
                                        SalesOrderNumber       = dataReader.GetString(indexOfSalesOrderNumber),
                                        PurchaseOrderNumber    = dataReader.GetNullableString(indexOfPurchaseOrderNumber),
                                        AccountNumber          = dataReader.GetNullableString(indexOfAccountNumber),
                                        CustomerID             = dataReader.GetInt32(indexOfCustomerID),
                                        SalesPersonID          = dataReader.GetNullableInt32(indexOfSalesPersonID),
                                        TerritoryID            = dataReader.GetNullableInt32(indexOfTerritoryID),
                                        BillToAddressID        = dataReader.GetInt32(indexOfBillToAddressID),
                                        ShipToAddressID        = dataReader.GetInt32(indexOfShipToAddressID),
                                        ShipMethodID           = dataReader.GetInt32(indexOfShipMethodID),
                                        CreditCardID           = dataReader.GetNullableInt32(indexOfCreditCardID),
                                        CreditCardApprovalCode = dataReader.GetNullableString(indexOfCreditCardApprovalCode),
                                        CurrencyRateID         = dataReader.GetNullableInt32(indexOfCurrencyRateID),
                                        SubTotal               = dataReader.GetDecimal(indexOfSubTotal),
                                        TaxAmt                 = dataReader.GetDecimal(indexOfTaxAmt),
                                        Freight                = dataReader.GetDecimal(indexOfFreight),
                                        TotalDue               = dataReader.GetDecimal(indexOfTotalDue),
                                        Comment                = dataReader.GetNullableString(indexOfComment),
                                        rowguid                = dataReader.GetGuid(indexOfrowguid),
                                        ModifiedDate           = dataReader.GetDateTime(indexOfModifiedDate),
                                    }));
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                }

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

                client.Transaction.Commit();
            }
        }
        public void Export_HumanResources_Employee()
        {
            LeafSQLClient client = new LeafSQLClient("http://localhost:6858/", "admin", "");

            if (client.Schema.Exists("AdventureWorks2012:HumanResources:Employee"))
            {
                return;
            }

            client.Transaction.Begin();

            client.Schema.Create("AdventureWorks2012:HumanResources:Employee");

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

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

                        using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                        {
                            int indexOfBusinessEntityID = dataReader.GetOrdinal("BusinessEntityID");
                            int indexOfNationalIDNumber = dataReader.GetOrdinal("NationalIDNumber");
                            int indexOfLoginID          = dataReader.GetOrdinal("LoginID");
                            int indexOfJobTitle         = dataReader.GetOrdinal("JobTitle");
                            int indexOfBirthDate        = dataReader.GetOrdinal("BirthDate");
                            int indexOfMaritalStatus    = dataReader.GetOrdinal("MaritalStatus");
                            int indexOfGender           = dataReader.GetOrdinal("Gender");
                            int indexOfHireDate         = dataReader.GetOrdinal("HireDate");
                            int indexOfSalariedFlag     = dataReader.GetOrdinal("SalariedFlag");
                            int indexOfVacationHours    = dataReader.GetOrdinal("VacationHours");
                            int indexOfSickLeaveHours   = dataReader.GetOrdinal("SickLeaveHours");
                            int indexOfCurrentFlag      = dataReader.GetOrdinal("CurrentFlag");
                            int indexOfrowguid          = dataReader.GetOrdinal("rowguid");
                            int indexOfModifiedDate     = dataReader.GetOrdinal("ModifiedDate");

                            int rowCount = 0;


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

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

                                try
                                {
                                    client.Document.Store("AdventureWorks2012:HumanResources:Employee", new Document(new Models.HumanResources_Employee
                                    {
                                        BusinessEntityID = dataReader.GetInt32(indexOfBusinessEntityID),
                                        NationalIDNumber = dataReader.GetString(indexOfNationalIDNumber),
                                        LoginID          = dataReader.GetString(indexOfLoginID),
                                        JobTitle         = dataReader.GetString(indexOfJobTitle),
                                        BirthDate        = dataReader.GetDateTime(indexOfBirthDate),
                                        MaritalStatus    = dataReader.GetString(indexOfMaritalStatus),
                                        Gender           = dataReader.GetString(indexOfGender),
                                        HireDate         = dataReader.GetDateTime(indexOfHireDate),
                                        SalariedFlag     = dataReader.GetBoolean(indexOfSalariedFlag),
                                        VacationHours    = dataReader.GetInt16(indexOfVacationHours),
                                        SickLeaveHours   = dataReader.GetInt16(indexOfSickLeaveHours),
                                        CurrentFlag      = dataReader.GetBoolean(indexOfCurrentFlag),
                                        rowguid          = dataReader.GetGuid(indexOfrowguid),
                                        ModifiedDate     = dataReader.GetDateTime(indexOfModifiedDate),
                                    }));
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                }

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

                client.Transaction.Commit();
            }
        }
Пример #22
0
        public void Export_Purchasing_PurchaseOrderHeader()
        {
            LeafSQLClient client = new LeafSQLClient("http://localhost:6858/", "admin", "");

            if (client.Schema.Exists("AdventureWorks2012:Purchasing:PurchaseOrderHeader"))
            {
                return;
            }

            client.Transaction.Begin();

            client.Schema.Create("AdventureWorks2012:Purchasing:PurchaseOrderHeader");

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

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

                        using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                        {
                            int indexOfPurchaseOrderID = dataReader.GetOrdinal("PurchaseOrderID");
                            int indexOfRevisionNumber  = dataReader.GetOrdinal("RevisionNumber");
                            int indexOfStatus          = dataReader.GetOrdinal("Status");
                            int indexOfEmployeeID      = dataReader.GetOrdinal("EmployeeID");
                            int indexOfVendorID        = dataReader.GetOrdinal("VendorID");
                            int indexOfShipMethodID    = dataReader.GetOrdinal("ShipMethodID");
                            int indexOfOrderDate       = dataReader.GetOrdinal("OrderDate");
                            int indexOfShipDate        = dataReader.GetOrdinal("ShipDate");
                            int indexOfSubTotal        = dataReader.GetOrdinal("SubTotal");
                            int indexOfTaxAmt          = dataReader.GetOrdinal("TaxAmt");
                            int indexOfFreight         = dataReader.GetOrdinal("Freight");
                            int indexOfTotalDue        = dataReader.GetOrdinal("TotalDue");
                            int indexOfModifiedDate    = dataReader.GetOrdinal("ModifiedDate");

                            int rowCount = 0;


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

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

                                try
                                {
                                    client.Document.Store("AdventureWorks2012:Purchasing:PurchaseOrderHeader", new Document(new Models.Purchasing_PurchaseOrderHeader
                                    {
                                        PurchaseOrderID = dataReader.GetInt32(indexOfPurchaseOrderID),
                                        RevisionNumber  = dataReader.GetByte(indexOfRevisionNumber),
                                        Status          = dataReader.GetByte(indexOfStatus),
                                        EmployeeID      = dataReader.GetInt32(indexOfEmployeeID),
                                        VendorID        = dataReader.GetInt32(indexOfVendorID),
                                        ShipMethodID    = dataReader.GetInt32(indexOfShipMethodID),
                                        OrderDate       = dataReader.GetDateTime(indexOfOrderDate),
                                        ShipDate        = dataReader.GetNullableDateTime(indexOfShipDate),
                                        SubTotal        = dataReader.GetDecimal(indexOfSubTotal),
                                        TaxAmt          = dataReader.GetDecimal(indexOfTaxAmt),
                                        Freight         = dataReader.GetDecimal(indexOfFreight),
                                        TotalDue        = dataReader.GetDecimal(indexOfTotalDue),
                                        ModifiedDate    = dataReader.GetDateTime(indexOfModifiedDate),
                                    }));
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                }

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

                client.Transaction.Commit();
            }
        }
Пример #23
0
        public void Export_Sales_SpecialOffer()
        {
            LeafSQLClient client = new LeafSQLClient("http://localhost:6858/", "admin", "");

            if (client.Schema.Exists("AdventureWorks2012:Sales:SpecialOffer"))
            {
                return;
            }

            client.Transaction.Begin();

            client.Schema.Create("AdventureWorks2012:Sales:SpecialOffer");

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

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

                        using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                        {
                            int indexOfSpecialOfferID = dataReader.GetOrdinal("SpecialOfferID");
                            int indexOfDescription    = dataReader.GetOrdinal("Description");
                            int indexOfDiscountPct    = dataReader.GetOrdinal("DiscountPct");
                            int indexOfType           = dataReader.GetOrdinal("Type");
                            int indexOfCategory       = dataReader.GetOrdinal("Category");
                            int indexOfStartDate      = dataReader.GetOrdinal("StartDate");
                            int indexOfEndDate        = dataReader.GetOrdinal("EndDate");
                            int indexOfMinQty         = dataReader.GetOrdinal("MinQty");
                            int indexOfMaxQty         = dataReader.GetOrdinal("MaxQty");
                            int indexOfrowguid        = dataReader.GetOrdinal("rowguid");
                            int indexOfModifiedDate   = dataReader.GetOrdinal("ModifiedDate");

                            int rowCount = 0;


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

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

                                try
                                {
                                    client.Document.Store("AdventureWorks2012:Sales:SpecialOffer", new Document(new Models.Sales_SpecialOffer
                                    {
                                        SpecialOfferID = dataReader.GetInt32(indexOfSpecialOfferID),
                                        Description    = dataReader.GetString(indexOfDescription),
                                        DiscountPct    = dataReader.GetDecimal(indexOfDiscountPct),
                                        Type           = dataReader.GetString(indexOfType),
                                        Category       = dataReader.GetString(indexOfCategory),
                                        StartDate      = dataReader.GetDateTime(indexOfStartDate),
                                        EndDate        = dataReader.GetDateTime(indexOfEndDate),
                                        MinQty         = dataReader.GetInt32(indexOfMinQty),
                                        MaxQty         = dataReader.GetNullableInt32(indexOfMaxQty),
                                        rowguid        = dataReader.GetGuid(indexOfrowguid),
                                        ModifiedDate   = dataReader.GetDateTime(indexOfModifiedDate),
                                    }));
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                }

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

                client.Transaction.Commit();
            }
        }
Пример #24
0
        public void Export_Production_BillOfMaterials()
        {
            LeafSQLClient client = new LeafSQLClient("http://localhost:6858/", "admin", "");

            if (client.Schema.Exists("AdventureWorks2012:Production:BillOfMaterials"))
            {
                return;
            }

            client.Transaction.Begin();

            client.Schema.Create("AdventureWorks2012:Production:BillOfMaterials");

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

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

                        using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                        {
                            int indexOfBillOfMaterialsID = dataReader.GetOrdinal("BillOfMaterialsID");
                            int indexOfProductAssemblyID = dataReader.GetOrdinal("ProductAssemblyID");
                            int indexOfComponentID       = dataReader.GetOrdinal("ComponentID");
                            int indexOfStartDate         = dataReader.GetOrdinal("StartDate");
                            int indexOfEndDate           = dataReader.GetOrdinal("EndDate");
                            int indexOfUnitMeasureCode   = dataReader.GetOrdinal("UnitMeasureCode");
                            int indexOfBOMLevel          = dataReader.GetOrdinal("BOMLevel");
                            int indexOfPerAssemblyQty    = dataReader.GetOrdinal("PerAssemblyQty");
                            int indexOfModifiedDate      = dataReader.GetOrdinal("ModifiedDate");

                            int rowCount = 0;


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

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

                                try
                                {
                                    client.Document.Store("AdventureWorks2012:Production:BillOfMaterials", new Document(new Models.Production_BillOfMaterials
                                    {
                                        BillOfMaterialsID = dataReader.GetInt32(indexOfBillOfMaterialsID),
                                        ProductAssemblyID = dataReader.GetNullableInt32(indexOfProductAssemblyID),
                                        ComponentID       = dataReader.GetInt32(indexOfComponentID),
                                        StartDate         = dataReader.GetDateTime(indexOfStartDate),
                                        EndDate           = dataReader.GetNullableDateTime(indexOfEndDate),
                                        UnitMeasureCode   = dataReader.GetString(indexOfUnitMeasureCode),
                                        BOMLevel          = dataReader.GetInt16(indexOfBOMLevel),
                                        PerAssemblyQty    = dataReader.GetDecimal(indexOfPerAssemblyQty),
                                        ModifiedDate      = dataReader.GetDateTime(indexOfModifiedDate),
                                    }));
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                }

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

                client.Transaction.Commit();
            }
        }
Пример #25
0
 public Transaction(LeafSQLClient client)
     : base(client)
 {
     this.client = client;
 }
Пример #26
0
        public void Export_dbo_ErrorLog()
        {
            LeafSQLClient client = new LeafSQLClient("http://localhost:6858/", "admin", "");

            if (client.Schema.Exists("AdventureWorks2012:dbo:ErrorLog"))
            {
                return;
            }

            client.Transaction.Begin();

            client.Schema.Create("AdventureWorks2012:dbo:ErrorLog");

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

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

                        using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                        {
                            int indexOfErrorLogID     = dataReader.GetOrdinal("ErrorLogID");
                            int indexOfErrorTime      = dataReader.GetOrdinal("ErrorTime");
                            int indexOfUserName       = dataReader.GetOrdinal("UserName");
                            int indexOfErrorNumber    = dataReader.GetOrdinal("ErrorNumber");
                            int indexOfErrorSeverity  = dataReader.GetOrdinal("ErrorSeverity");
                            int indexOfErrorState     = dataReader.GetOrdinal("ErrorState");
                            int indexOfErrorProcedure = dataReader.GetOrdinal("ErrorProcedure");
                            int indexOfErrorLine      = dataReader.GetOrdinal("ErrorLine");
                            int indexOfErrorMessage   = dataReader.GetOrdinal("ErrorMessage");

                            int rowCount = 0;


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

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

                                try
                                {
                                    client.Document.Store("AdventureWorks2012:dbo:ErrorLog", new Document(new Models.dbo_ErrorLog
                                    {
                                        ErrorLogID     = dataReader.GetInt32(indexOfErrorLogID),
                                        ErrorTime      = dataReader.GetDateTime(indexOfErrorTime),
                                        UserName       = dataReader.GetString(indexOfUserName),
                                        ErrorNumber    = dataReader.GetInt32(indexOfErrorNumber),
                                        ErrorSeverity  = dataReader.GetNullableInt32(indexOfErrorSeverity),
                                        ErrorState     = dataReader.GetNullableInt32(indexOfErrorState),
                                        ErrorProcedure = dataReader.GetNullableString(indexOfErrorProcedure),
                                        ErrorLine      = dataReader.GetNullableInt32(indexOfErrorLine),
                                        ErrorMessage   = dataReader.GetString(indexOfErrorMessage),
                                    }));
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                }

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

                client.Transaction.Commit();
            }
        }
        public void Export_Purchasing_ProductVendor()
        {
            LeafSQLClient client = new LeafSQLClient("http://localhost:6858/", "admin", "");

            if (client.Schema.Exists("AdventureWorks2012:Purchasing:ProductVendor"))
            {
                return;
            }

            client.Transaction.Begin();

            client.Schema.Create("AdventureWorks2012:Purchasing:ProductVendor");

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

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

                        using (SqlDataReader dataReader = command.ExecuteReader(System.Data.CommandBehavior.CloseConnection))
                        {
                            int indexOfProductID        = dataReader.GetOrdinal("ProductID");
                            int indexOfBusinessEntityID = dataReader.GetOrdinal("BusinessEntityID");
                            int indexOfAverageLeadTime  = dataReader.GetOrdinal("AverageLeadTime");
                            int indexOfStandardPrice    = dataReader.GetOrdinal("StandardPrice");
                            int indexOfLastReceiptCost  = dataReader.GetOrdinal("LastReceiptCost");
                            int indexOfLastReceiptDate  = dataReader.GetOrdinal("LastReceiptDate");
                            int indexOfMinOrderQty      = dataReader.GetOrdinal("MinOrderQty");
                            int indexOfMaxOrderQty      = dataReader.GetOrdinal("MaxOrderQty");
                            int indexOfOnOrderQty       = dataReader.GetOrdinal("OnOrderQty");
                            int indexOfUnitMeasureCode  = dataReader.GetOrdinal("UnitMeasureCode");
                            int indexOfModifiedDate     = dataReader.GetOrdinal("ModifiedDate");

                            int rowCount = 0;


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

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

                                try
                                {
                                    client.Document.Store("AdventureWorks2012:Purchasing:ProductVendor", new Document(new Models.Purchasing_ProductVendor
                                    {
                                        ProductID        = dataReader.GetInt32(indexOfProductID),
                                        BusinessEntityID = dataReader.GetInt32(indexOfBusinessEntityID),
                                        AverageLeadTime  = dataReader.GetInt32(indexOfAverageLeadTime),
                                        StandardPrice    = dataReader.GetDecimal(indexOfStandardPrice),
                                        LastReceiptCost  = dataReader.GetNullableDecimal(indexOfLastReceiptCost),
                                        LastReceiptDate  = dataReader.GetNullableDateTime(indexOfLastReceiptDate),
                                        MinOrderQty      = dataReader.GetInt32(indexOfMinOrderQty),
                                        MaxOrderQty      = dataReader.GetInt32(indexOfMaxOrderQty),
                                        OnOrderQty       = dataReader.GetNullableInt32(indexOfOnOrderQty),
                                        UnitMeasureCode  = dataReader.GetString(indexOfUnitMeasureCode),
                                        ModifiedDate     = dataReader.GetDateTime(indexOfModifiedDate),
                                    }));
                                }
                                catch (Exception ex)
                                {
                                    Console.WriteLine(ex.Message);
                                }

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

                client.Transaction.Commit();
            }
        }
Пример #28
0
 public Security(LeafSQLClient client)
     : base(client)
 {
     this.client = client;
 }
Пример #29
0
        public void Export_Production_ProductReview()
        {
            LeafSQLClient client = new LeafSQLClient("http://localhost:6858/", "admin", "");

            if (client.Schema.Exists("AdventureWorks2012:Production:ProductReview"))
            {
                return;
            }

            client.Transaction.Begin();

            client.Schema.Create("AdventureWorks2012:Production:ProductReview");

            using (SqlConnection connection = new SqlConnection("Server=.;Database=AdventureWorks2012;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("AdventureWorks2012:Production:ProductReview: {0}", rowCount);
                                }

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

                                try
                                {
                                    client.Document.Store("AdventureWorks2012:Production:ProductReview", new Document(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();
            }
        }
Пример #30
0
 public Settings(LeafSQLClient client)
     : base(client)
 {
     this.client = client;
 }