Example #1
0
        static void Main(string[] args)
        {
            ConsoleColor old = Console.ForegroundColor;
            try{
                var props = new ConnectionProperties();
                using (var frm = new ConnectionDialog(props, true, Assembly.LoadFrom))
                {
                    var result = frm.ShowDialog();
                    if (result != System.Windows.Forms.DialogResult.OK)
                        return;
                }

                var cxi = new FakeConnection();
                new ConnectionPropertiesSerializer().Serialize(cxi.DriverData, props);

                var driver = new MongoDynamicDataContextDriver();

                List<Assembly> assemblies = props.AssemblyLocations.Select(Assembly.LoadFrom).ToList();
                var code = driver.GetStaticCodeFiles()
                    .Concat(new string[] {driver.GenerateDynamicCode(props, assemblies, "", "driver")});
                if(props.InitializationQuery != null)
                    code = code.Concat(new string[]{driver.GenerateCustomInitQuery(props.InitializationQuery, "driver")});

                Console.ForegroundColor = ConsoleColor.DarkCyan;
                Console.WriteLine("------------------------------------------------");
                foreach (string s in code)
                {
                    Console.WriteLine(s);
                    Console.WriteLine("------------------------------------------------");
                }
                Console.ForegroundColor = old;

                using (var frm = new SaveFileDialog())
                {
                    var result = frm.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        using (StreamWriter writer = new StreamWriter(frm.OpenFile()))
                        {
                            foreach (string s in code)
                            {
                                writer.WriteLine(s);
                                writer.WriteLine("---------------------------------------------------");
                            }

                            writer.Flush();
                        }

                    }
                }

            }catch(Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex);
            }
            finally{
                Console.ForegroundColor = old;
            }
        }
        public void AdditionalOptions_ExplicitAllowSave_RoundTripEqual()
        {
            var prop = new ConnectionProperties
            {
                AdditionalOptions = new ConnectionAdditionalOptions
                {
                    ExplicitSaveAllowedTypes =
                        {
                            "String"
                        }
                }
            };

            //
            //Act
            //do the round trip
            var serializer = new ConnectionPropertiesSerializer();
            XElement element = new XElement("test");
            serializer.Serialize(element, prop);

            ConnectionProperties prop2 = serializer.Deserialize(element);

            //Assert
            Assert.AreEqual(prop, prop2);
        }
        /// <summary>
        /// Gets the additional namespaces that should be imported for queries using this driver
        /// </summary>
        /// <param name="props">the deserialized ConnectionProperties object.</param>
        /// <returns>The namespaces that should be imported as strings</returns>
        public static IEnumerable<string> GetNamespacesToAdd(ConnectionProperties props)
        {
            IEnumerable<string> ret = new[]
                {
                    "MongoDB.Driver.Builders",
                    "MongoDB.Driver",
                };

            if(!string.IsNullOrEmpty(props.SelectedDatabase))
            {
                ret = ret.Concat(
                props.CollectionTypeMappings[props.SelectedDatabase].Select(x => x.CollectionType)
                    .Where(x => !string.IsNullOrEmpty(x))
                    .Select(name =>
                    {
                        name = name.Split(',').First();
                        int lastDot = name.LastIndexOf('.');
                        if (lastDot <= -1)
                            return null;

                        return name.Substring(0, lastDot);
                    }).Where(x => !string.IsNullOrEmpty(x)));
            }

            return ret.Distinct();
        }
        public AdditionalOptions(ConnectionProperties props, ICollection<Type> loadedTypes)
        {
            this.mProps = props;
            this.mLoadedTypes = loadedTypes;

            InitializeComponent();
            this.addToolStripMenuItem.Click += AddToolStripMenuItemOnClick;
            this.removeToolStripMenuItem.Click += RemoveToolStripMenuItemOnClick;

            InitToolTips();

            LoadFromProps();
        }
        public void TableOperationTest()
        {
            var client = new PhoenixClient(null);
            string connId = GenerateRandomConnId();
            RequestOptions options = RequestOptions.GetVNetDefaultOptions();
            // In VNET mode, PQS requests will be http://<PQS workernode ip>:8765
            options.AlternativeHost = "10.17.0.13";
            OpenConnectionResponse openConnResponse = null;
            try
            {
                // Opening connection
                pbc::MapField<string, string> info = new pbc::MapField<string, string>();
                openConnResponse = client.OpenConnectionRequestAsync(connId, info, options).Result;
                // Syncing connection
                ConnectionProperties connProperties = new ConnectionProperties
                {
                    HasAutoCommit = true,
                    AutoCommit = true,
                    HasReadOnly = true,
                    ReadOnly = false,
                    TransactionIsolation = 0,
                    Catalog = "",
                    Schema = "",
                    IsDirty = true
                };
                client.ConnectionSyncRequestAsync(connId, connProperties, options).Wait();

                // List system tables
                pbc.RepeatedField<string> list = new pbc.RepeatedField<string>();
                list.Add("SYSTEM TABLE");
                ResultSetResponse tablesResponse = client.TablesRequestAsync("", "", "", list, true, connId, options).Result;
                Assert.AreEqual(4, tablesResponse.FirstFrame.Rows.Count);

                // List all table types
                ResultSetResponse tableTypeResponse = client.TableTypesRequestAsync(connId, options).Result;
                Assert.AreEqual(6, tableTypeResponse.FirstFrame.Rows.Count);
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
            finally
            {
                if (openConnResponse != null)
                {
                    client.CloseConnectionRequestAsync(connId, options).Wait();
                    openConnResponse = null;
                }
            }
        }
        public static ConnectionList Build(int leftPerceptrons, int rightPerceptrons, ConnectionProperties connectionProperties)
        {
            var connectionList = new ConnectionList();

            for (int i = 0; i < leftPerceptrons; i++)
            {
                for (int j = 0; j < rightPerceptrons; j++)
                {
                    connectionList.Add(new Connection(i + 1, j + 1, connectionProperties));
                }
            }

            return connectionList;
        }
        public void AssemblyLocationsDiffer_OneIsNull_NotEqual()
        {
            var props1 = new ConnectionProperties
                    {
                        AssemblyLocations =
                            {
                                "abc"
                            }
                    };
            var props2 = new ConnectionProperties
                    {
                    };

            Assert.IsFalse(object.Equals(props1, props2));
        }
		public System.Data.OleDb.OleDbCommand CreateStatement(System.Data.OleDb.OleDbConnection connection) {
		    System.Data.OleDb.OleDbCommand command = connection.CreateCommand();
		    System.Data.OleDb.OleDbTransaction transaction;
		    if (this[connection] != null) {
			ConnectionProperties Properties = ((ConnectionProperties) this[connection]);
			transaction = Properties.Transaction;
			command.Transaction = transaction;
		    } else {
			ConnectionProperties TempProp = new ConnectionProperties();
			TempProp.AutoCommit=false;
			TempProp.TransactionLevel = 0;
			command.Transaction = TempProp.Transaction;
			Add(connection, TempProp);
		    }
		    return command;
		}
		public void SetAutoCommit(System.Data.OleDb.OleDbConnection connection, bool boolean) {
		    if (this[connection] != null) {
			ConnectionProperties Properties = ((ConnectionProperties) this[connection]);
			Properties.AutoCommit = boolean;
			if(!boolean) {
			    System.Data.OleDb.OleDbTransaction transaction =  Properties.Transaction;
			    if (Properties.TransactionLevel == 0) {
				transaction = connection.BeginTransaction();
			    } else {
				transaction = connection.BeginTransaction(Properties.TransactionLevel);
			    }
			}
		    } else {
			ConnectionProperties TempProp = new ConnectionProperties();
			TempProp.AutoCommit=boolean;
			TempProp.TransactionLevel=0;
			if(boolean)
			    TempProp.Transaction  = connection.BeginTransaction();
			Add(connection, TempProp);
		    }
		}
        public void AssemblyLocationsDiffer_Values_NotEqual()
        {
            var props1 = new ConnectionProperties
            {
                AssemblyLocations =
                            {
                                "abc",
                                "DEF"
                            }
            };
            var props2 = new ConnectionProperties
            {
                AssemblyLocations =
                    {
                        "abc",
                        "GHI"
                    }
            };

            Assert.IsFalse(object.Equals(props1, props2));
        }
        public void AssemblyLocation_RoundTrip_Equal()
        {
            var prop = new ConnectionProperties
            {
                AssemblyLocations =
                    {
                        "abc"
                    }
            };

            //
            //Act
            //do the round trip
            var serializer = new ConnectionPropertiesSerializer();
            XElement element = new XElement("test");
            serializer.Serialize(element, prop);

            ConnectionProperties prop2 = serializer.Deserialize(element);

            //Assert
            Assert.AreEqual(prop, prop2);
        }
        public void AdditionalOptions_BooleanValues_RoundTripEqual()
        {
            var prop = new ConnectionProperties
            {
                AdditionalOptions = new ConnectionAdditionalOptions
                                        {
                                            AllowSaveForAllTypes = true,
                                            BlanketIgnoreExtraElements = true
                                        }
            };

            //
            //Act
            //do the round trip
            var serializer = new ConnectionPropertiesSerializer();
            XElement element = new XElement("test");
            serializer.Serialize(element, prop);

            ConnectionProperties prop2 = serializer.Deserialize(element);

            //Assert
            Assert.AreEqual(prop, prop2);
        }
Example #13
0
        private async void Open()
        {
            try
            {
                var fileDialog = new OpenFileDialog();
                fileDialog.Filter =
                    "SQL script files(*.sql)|*.sql|Access Files(*.mdb)|*.mdb|Access 2007 Files(*.accdb)|*.accdb|Excel files (*.xls;*.xlsx)|*.xls;*.xlsx|MSI files (*.msi)|*.msi|SQLite files (*.*)|*.*|SQL Server Compact files (*.sdf)|*.sdf|SQL Server Compact 4.0 files (*.sdf)|*.sdf";
                fileDialog.RestoreDirectory = true;
                var currentDirectory = Environment.CurrentDirectory;

                if (fileDialog.ShowDialog(this) == DialogResult.OK)
                {
                    if (Environment.CurrentDirectory != currentDirectory)
                    {
                        Environment.CurrentDirectory = currentDirectory;
                    }

                    var       fileName         = fileDialog.FileName;
                    var       extension        = Path.GetExtension(fileName).ToLower();
                    string    connectionString = null;
                    IProvider provider         = null;

                    switch (fileDialog.FilterIndex)
                    {
                    case 1:
                        LoadFiles(fileDialog.FileNames);
                        break;

                    case 2:
                        connectionString = "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" + fileName;
                        provider         = ProviderFactory.CreateProvider(ProviderName.OleDb);
                        break;

                    case 3:
                        connectionString = $"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={fileName};Persist Security Info=False";
                        provider         = ProviderFactory.CreateProvider(ProviderName.OleDb);
                        break;

                    case 4:
                        if (extension == ".xls")
                        {
                            connectionString = Environment.Is64BitProcess
                                    ? $"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={fileName};Extended Properties=Excel 8.0"
                                    : $"Provider=Microsoft.Jet.OLEDB.4.0;Data Source={fileName};Extended Properties=Excel 8.0";
                        }
                        else
                        {
                            connectionString = $"Provider=Microsoft.ACE.OLEDB.12.0;Data Source={fileName};Extended Properties=Excel 12.0";
                        }

                        provider = ProviderFactory.CreateProvider(ProviderName.OleDb);
                        break;

                    case 5:
                        connectionString = $"{ConnectionStringKeyword.DataSource}={fileName}";
                        provider         = ProviderFactory.CreateProvider("Msi");
                        break;

                    case 6:
                        connectionString = $"{ConnectionStringKeyword.DataSource}={fileName}";
                        provider         = ProviderFactory.CreateProvider(ProviderName.SqLite);
                        break;

                    case 7:
                        connectionString = $"{ConnectionStringKeyword.DataSource}={fileName}";
                        provider         = ProviderFactory.CreateProvider("SqlServerCe");
                        break;

                    case 8:
                        connectionString = $"{ConnectionStringKeyword.DataSource}={fileName}";
                        provider         = ProviderFactory.CreateProvider(ProviderName.SqlServerCe40);
                        break;

                    default:
                        throw new NotSupportedException();
                    }

                    if (provider != null)
                    {
                        var connection = provider.CreateConnection(connectionString);
                        await connection.OpenAsync(CancellationToken.None);

                        var connectionProperties = new ConnectionProperties
                        {
                            ConnectionName   = null,
                            ProviderName     = provider.Name,
                            ConnectionString = connectionString
                        };

                        var node    = DataCommanderApplication.Instance.ConnectionsConfigurationNode;
                        var subNode = new ConfigurationNode(null);
                        node.AddChildNode(subNode);
                        ConnectionPropertiesRepository.Save(connectionProperties, subNode);

                        var queryForm = new QueryForm(this, MdiChildren.Length, provider, connectionString, connection, _statusBar, _colorTheme);

                        queryForm.MdiParent = this;
                        queryForm.Font      = SelectedFont;
                        queryForm.Show();
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Write(LogLevel.Error, ex.ToLogString());
                MessageBox.Show(this, ex.ToString());
            }
        }
Example #14
0
        public void SimpleTest()
        {
            var            client  = new PhoenixClient(_credentials);
            string         connId  = GenerateRandomConnId();
            RequestOptions options = RequestOptions.GetGatewayDefaultOptions();

            // In gateway mode, url format will be https://<cluster dns name>.azurehdinsight.net/hbasephoenix<N>/
            // Requests sent to hbasephoenix0/ will be forwarded to PQS on workernode0
            options.AlternativeEndpoint = "hbasephoenix0/";
            string tableName = "Persons" + connId;
            OpenConnectionResponse  openConnResponse        = null;
            CreateStatementResponse createStatementResponse = null;

            try
            {
                // Opening connection
                pbc::MapField <string, string> info = new pbc::MapField <string, string>();
                openConnResponse = client.OpenConnectionRequestAsync(connId, info, options).Result;
                // Syncing connection
                ConnectionProperties connProperties = new ConnectionProperties
                {
                    HasAutoCommit        = true,
                    AutoCommit           = true,
                    HasReadOnly          = true,
                    ReadOnly             = false,
                    TransactionIsolation = 0,
                    Catalog = "",
                    Schema  = "",
                    IsDirty = true
                };
                client.ConnectionSyncRequestAsync(connId, connProperties, options).Wait();


                createStatementResponse = client.CreateStatementRequestAsync(connId, options).Result;
                // Running query 1
                string sql1 = "CREATE TABLE " + tableName + " (LastName varchar(255) PRIMARY KEY,FirstName varchar(255))";
                client.PrepareAndExecuteRequestAsync(connId, sql1, createStatementResponse.StatementId, long.MaxValue, int.MaxValue, options).Wait();

                // Running query 2
                string sql2 = "UPSERT INTO " + tableName + " VALUES ('d1','x1')";
                client.PrepareAndExecuteRequestAsync(connId, sql2, createStatementResponse.StatementId, long.MaxValue, int.MaxValue, options).Wait();

                // Running query 3
                string          sql3          = "select count(*) from " + tableName;
                ExecuteResponse execResponse3 = client.PrepareAndExecuteRequestAsync(connId, sql3, createStatementResponse.StatementId, long.MaxValue, int.MaxValue, options).Result;
                long            count         = execResponse3.Results[0].FirstFrame.Rows[0].Value[0].ScalarValue.NumberValue;
                Assert.AreEqual(1, count);

                // Running query 4
                string sql4 = "DROP TABLE " + tableName;
                client.PrepareAndExecuteRequestAsync(connId, sql4, createStatementResponse.StatementId, long.MaxValue, int.MaxValue, options).Wait();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
            finally
            {
                if (createStatementResponse != null)
                {
                    client.CloseStatementRequestAsync(connId, createStatementResponse.StatementId, options).Wait();
                    createStatementResponse = null;
                }

                if (openConnResponse != null)
                {
                    client.CloseConnectionRequestAsync(connId, options).Wait();
                    openConnResponse = null;
                }
            }
        }
Example #15
0
        public static void Synchronize()
        {
            ConnectionProperties
                remote = new ConnectionProperties(Settings.Default.RemoteServer, Settings.Default.RemoteDb),
                local  = new ConnectionProperties(Settings.Default.LocalServer, Settings.Default.LocalDb);

            using (var service = new SchemaServiceClient()) {
                //check for schema update
                byte version = service.GetSchemaVersion();
                if (version > Settings.Default.SchemaVersion)
                {
                    //synchronise schema
                    StructureProject structure = new StructureProject(remote, local);

                    structure.ComparisonOptions.IgnoreIdentitySeedAndIncrement = true;
                    structure.MappedObjects.ExcludeAllFromComparison();

                    //select the desired tables and triggers
                    var tables = Settings.Default.Tables.Split(',');
                    structure.MappedTables.IncludeInComparison(tables.Select(t => '^' + t + '$').ToArray());
                    structure.MappedTriggers.IncludeInComparison(tables.Select(t => '^' + t + "_TimeStamp$").ToArray());

                    structure.ComparedObjects.IncludeAllInSynchronization();
                    Synchronise(structure);

                    Settings.Default.SchemaVersion = version;
                    Settings.Default.Save();
                }

                //server to client
                DataProject down = new DataProject(remote, local);
#pragma warning disable 612
                down.ComparisonOptions.CompareAdditionalRows = false;
#pragma warning restore 612

                //only retrieve rows which have changed since last sync
                string timestamp = "TimeStamp > '" + Settings.Default.LastSync.ToString("yyyy-MM-dd HH:mm:ss") + "'";
                foreach (MappedDataObject <Table> table in down.MappedTables)
                {
                    table.WhereClause.SourceFilter = timestamp;
                    table.WhereClause.UseSourceFilterForDestination = false;
                }

                down.ComparedObjects.IncludeAllInSynchronization();
                Synchronise(down);

                //client to server
                DataProject up = new DataProject(local, remote);
#pragma warning disable 612
                up.ComparisonOptions.CompareAdditionalRows = false;
#pragma warning restore 612

                using (var con = new SqlConnection(Settings.Default.Local))
                    foreach (MappedDataObject <Table> table in up.MappedTables)
                    {
                        StringBuilder ids = new StringBuilder("ID in (");
                        using (var com = new SqlCommand("select ID from " + table.SourceName + " where " + timestamp, con)) {
                            con.Open();
                            using (var results = com.ExecuteReader(CommandBehavior.CloseConnection))
                                while (results.Read())
                                {
                                    ids.Append(results[0]).Append(',');
                                }
                        }
                        if (ids[ids.Length - 1] == '(')
                        {
                            table.IncludeInComparison = false;
                        }
                        else
                        {
                            table.WhereClause.SourceFilter = ids.Remove(ids.Length - 1, 1).Append(')').ToString();
                        }
                    }

                try {
                    up.ComparedObjects.IncludeAllInSynchronization();
                    Synchronise(up);
                }
                catch (NoSelectedForOperationObjectsException) { }

                Settings.Default.LastSync = DateTime.Now;
                Settings.Default.Save();

                //do we have an ID range?
                if (Settings.Default.MaxID == 0)
                {
                    var range = service.GetIdRange(Environment.MachineName);
                    Settings.Default.MinID = range.Min;
                    Settings.Default.MaxID = range.Max;
                    Settings.Default.Save();
                }
            }

            //reseed the client
            using (var db = new SqlConnection(Settings.Default.Local))
                Repository.Repository.Reseed(Settings.Default.MinID, Settings.Default.MaxID, db);
        }
        /// <summary>
        /// This request is used to ensure that the client and server have a consistent view of the database properties.
        /// </summary>
        public async Task<ConnectionSyncResponse> ConnectionSyncRequestAsync(string connectionId, ConnectionProperties props, RequestOptions options)
        {
            ConnectionSyncRequest req = new ConnectionSyncRequest
            {
                ConnectionId = connectionId,
                ConnProps = props
            };

            WireMessage msg = new WireMessage
            {
                Name = Constants.WireMessagePrefix + "ConnectionSyncRequest",
                WrappedMessage = req.ToByteString()
            };

            using (Response webResponse = await PostRequestAsync(msg.ToByteArray(), options))
            {
                if (webResponse.WebResponse.StatusCode != HttpStatusCode.OK)
                {
                    WireMessage output = WireMessage.Parser.ParseFrom(webResponse.WebResponse.GetResponseStream());
                    ErrorResponse res = ErrorResponse.Parser.ParseFrom(output.WrappedMessage);
                    throw new WebException(
                        string.Format(
                            "ConnectionSyncRequestAsync failed! connectionId: {0}, Response code was: {1}, Response body was: {2}",
                            connectionId,
                            webResponse.WebResponse.StatusCode,
                            res.ToString()));
                }
                else
                {
                    WireMessage output = WireMessage.Parser.ParseFrom(webResponse.WebResponse.GetResponseStream());
                    ConnectionSyncResponse res = ConnectionSyncResponse.Parser.ParseFrom(output.WrappedMessage);
                    return res;
                }
            }
        }
Example #17
0
        public void ManyRowBatchInsertTest()
        {
            var            client  = new PhoenixClient(_credentials);
            string         connId  = GenerateRandomConnId();
            RequestOptions options = RequestOptions.GetGatewayDefaultOptions();

            // In gateway mode, url format will be https://<cluster dns name>.azurehdinsight.net/hbasephoenix<N>/
            // Requests sent to hbasephoenix0/ will be forwarded to PQS on workernode0
            options.AlternativeEndpoint = "hbasephoenix0/";
            string tableName = "Persons" + connId;

            OpenConnectionResponse  openConnResponse        = null;
            CreateStatementResponse createStatementResponse = null;

            try
            {
                // Opening connection
                pbc::MapField <string, string> info = new pbc::MapField <string, string>();
                openConnResponse = client.OpenConnectionRequestAsync(connId, info, options).Result;
                // Syncing connection
                ConnectionProperties connProperties = new ConnectionProperties
                {
                    HasAutoCommit        = true,
                    AutoCommit           = true,
                    HasReadOnly          = true,
                    ReadOnly             = false,
                    TransactionIsolation = 0,
                    Catalog = "",
                    Schema  = "",
                    IsDirty = true
                };
                client.ConnectionSyncRequestAsync(connId, connProperties, options).Wait();

                // Creating statement
                createStatementResponse = client.CreateStatementRequestAsync(connId, options).Result;

                // Running query 1
                string          sql1          = "CREATE TABLE " + tableName + " (LastName varchar(255) PRIMARY KEY,FirstName varchar(255))";
                ExecuteResponse execResponse1 = client.PrepareAndExecuteRequestAsync(connId, sql1, createStatementResponse.StatementId, long.MaxValue, int.MaxValue, options).Result;

                // Running query 2
                // Batching two sqls in a single HTTP request
                pbc::RepeatedField <string> list = new pbc.RepeatedField <string>();
                list.Add("UPSERT INTO " + tableName + " VALUES('d1','x1')");
                list.Add("UPSERT INTO " + tableName + " VALUES('d2','x2')");
                ExecuteBatchResponse execResponse2 = client.PrepareAndExecuteBatchRequestAsync(connId, createStatementResponse.StatementId, list, options).Result;

                // Running query 3
                string          sql3          = "select count(*) from " + tableName;
                ExecuteResponse execResponse3 = client.PrepareAndExecuteRequestAsync(connId, sql3, createStatementResponse.StatementId, long.MaxValue, int.MaxValue, options).Result;
                long            count3        = execResponse3.Results[0].FirstFrame.Rows[0].Value[0].ScalarValue.NumberValue;
                Assert.AreEqual(2, count3);

                // Running query 4
                // Batching two sqls in a single HTTP request
                // Creating statement 2
                string          sql4                     = "UPSERT INTO " + tableName + " VALUES (?,?)";
                PrepareResponse prepareResponse          = client.PrepareRequestAsync(connId, sql4, int.MaxValue, options).Result;
                StatementHandle statementHandle          = prepareResponse.Statement;
                pbc::RepeatedField <UpdateBatch> updates = new pbc.RepeatedField <UpdateBatch>();
                for (int i = 3; i < 10; i++)
                {
                    pbc::RepeatedField <TypedValue> parameterValues = new pbc.RepeatedField <TypedValue>();
                    TypedValue v1 = new TypedValue
                    {
                        StringValue = "d" + i,
                        Type        = Rep.String
                    };
                    TypedValue v2 = new TypedValue
                    {
                        StringValue = "x" + i,
                        Type        = Rep.String
                    };
                    parameterValues.Add(v1);
                    parameterValues.Add(v2);
                    UpdateBatch batch = new UpdateBatch
                    {
                        ParameterValues = parameterValues
                    };
                    updates.Add(batch);
                }
                ExecuteBatchResponse execResponse4 = client.ExecuteBatchRequestAsync(connId, statementHandle.Id, updates, options).Result;

                // Running query 5
                string          sql5          = "select count(*) from " + tableName;
                ExecuteResponse execResponse5 = client.PrepareAndExecuteRequestAsync(connId, sql5, createStatementResponse.StatementId, long.MaxValue, int.MaxValue, options).Result;
                long            count5        = execResponse5.Results[0].FirstFrame.Rows[0].Value[0].ScalarValue.NumberValue;
                Assert.AreEqual(9, count5);

                // Running query 5
                string sql6 = "DROP TABLE " + tableName;
                client.PrepareAndExecuteRequestAsync(connId, sql6, createStatementResponse.StatementId, long.MaxValue, int.MaxValue, options).Wait();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
            finally
            {
                if (createStatementResponse != null)
                {
                    client.CloseStatementRequestAsync(connId, createStatementResponse.StatementId, options).Wait();
                    createStatementResponse = null;
                }

                if (openConnResponse != null)
                {
                    client.CloseConnectionRequestAsync(connId, options).Wait();
                    openConnResponse = null;
                }
            }
        }
Example #18
0
 internal CypherSession(ConnectionProperties connectionProperties)
     : this(connectionProperties, new WebClient(connectionProperties.BuildBasicAuthCredentials()))
 {
 }
Example #19
0
        public void SetConfig(IDMEEditor pbl, IDMLogger plogger, IUtil putil, string[] args, PassedArgs e, IErrorsInfo per)
        {
            Logger      = plogger;
            ErrorObject = per;
            DMEEditor   = pbl;
            Visutil     = (IVisUtil)e.Objects.Where(c => c.Name == "VISUTIL").FirstOrDefault().obj;

            branch       = (IBranch)e.Objects.Where(c => c.Name == "Branch").FirstOrDefault().obj;
            ParentBranch = (IBranch)e.Objects.Where(c => c.Name == "ParentBranch").FirstOrDefault().obj;
            webAPIData   = DMEEditor.GetDataSource(e.DatasourceName);
            if (webAPIData != null)
            {
                // webAPIData.Dataconnection.OpenConnection();
                DMEEditor.OpenDataSource(e.DatasourceName);
                CurrentEntity = e.CurrentEntity;
                ConnectionProperties cn = DMEEditor.ConfigEditor.DataConnections.Where(p => string.Equals(p.ConnectionName, e.DatasourceName, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();
                ent = webAPIData.Entities.Where(o => string.Equals(o.EntityName, e.CurrentEntity, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

                ls = ent.Fields;
                this.dataGridView1.DataSource = DataBindingSource;
                DataGridView grid = dv.CreateGrid();
                if (ent.Filters == null)
                {
                    ent.Filters = new List <ReportFilter>();
                }
                ent.Filters.Clear();
                for (int i = 0; i <= ls.Count - 1; i++)
                {
                    ReportFilter r = new ReportFilter();
                    r.FieldName = ls[i].fieldname;
                    r.Operator  = "=";
                    ent.Filters.Add(r);
                    FieldNames.Add(ls[i].fieldname);
                }
                filtersBindingSource.DataSource = ent.Filters;
                if (lsop == null)
                {
                    lsop = new List <string> {
                        "=", ">=", "<=", ">", "<"
                    };
                }
                grid.AutoGenerateColumns = false;
                grid.DataSource          = this.filtersBindingSource;
                grid.Columns.Add(dv.CreateComoboBoxColumnForGrid("FieldName", "Column", FieldNames));
                grid.Columns.Add(dv.CreateComoboBoxColumnForGrid("Operator", "Operator", lsop));
                grid.Columns.Add(dv.CreateTextColumnForGrid("FilterValue", "Value"));

                grid.DataError += Grid_DataError;
                //    grid.AllowUserToAddRows = true;

                grid.Left   = 5;
                grid.Top    = 50;
                grid.Height = 220;
                grid.Width  = FilterPanel.Width - 25;
                FilterPanel.Controls.Add(grid);
                grid.Dock = DockStyle.Fill;
            }
            else
            {
                MessageBox.Show("Error Could not Find WebApi Datasource", "BeepDM");
            }

            this.GetDataButton.Click += GetDataButton_Click;
        }
Example #20
0
 public override void Initialize()
 {
     cp   = new ConnectionProperties();
     data = new byte[1024];
 }
        public void AssemblyLocationsSameValues_Equal()
        {
            var props1 = new ConnectionProperties
            {
                AssemblyLocations =
                            {
                                "abc",
                                "DEF"
                            }
            };
            var props2 = new ConnectionProperties
            {
                AssemblyLocations =
                    {
                        "abc",
                        "DEF"
                    }
            };

            Assert.IsTrue(object.Equals(props1, props2));
            var hash1 = props1.GetHashCode();
            var hash2 = props2.GetHashCode();
            Assert.AreEqual(hash1, hash2);
        }
        public void ConnectionStringsDiffer_NotEqual()
        {
            var props1 = new ConnectionProperties
                    {
                        ConnectionString = "abcdef"
                    };
            var props2 = new ConnectionProperties
                    {
                        ConnectionString = "ghijkl"
                    };

            Assert.IsFalse(object.Equals(props1, props2));
        }
Example #23
0
        public IDataSource CreateNewDataSourceConnection(string pdatasourcename)
        {
            ConnectionProperties cn = ConfigEditor.DataConnections.Where(f => f.ConnectionName.Equals(pdatasourcename, StringComparison.OrdinalIgnoreCase)).FirstOrDefault();

            ErrorObject.Flag = Errors.Ok;
            IDataSource ds = null;

            if (cn != null)
            {
                ConnectionDriversConfig driversConfig = Utilfunction.LinkConnection2Drivers(cn);
                if (ConfigEditor.DataSourcesClasses.Where(x => x.className == driversConfig.classHandler).Any())
                {
                    string packagename = ConfigEditor.DataSourcesClasses.Where(x => x.className == driversConfig.classHandler).FirstOrDefault().PackageName;
                    //  Type adc = Type.GetType(packagename);
                    Type            adc  = assemblyHandler.GetType(packagename);
                    ConstructorInfo ctor = adc.GetConstructors().First();
                    ObjectActivator <IDataSource> createdActivator = GetActivator <IDataSource>(ctor);
                    //create an instance:
                    ds = createdActivator(cn.ConnectionName, Logger, this, cn.DatabaseType, ErrorObject);
                }

                try
                {
                    if (ds != null)
                    {
                        ds.Dataconnection.ConnectionProp   = cn;
                        ds.Dataconnection.DataSourceDriver = driversConfig;
                        //  ds.ConnectionStatus = ds.Dataconnection.OpenConnection();
                        DataSources.Add(ds);
                        return(ds);
                    }
                    else
                    {
                        AddLogMessage("Fail", "Could Find DataSource Drivers", DateTime.Now, 0, pdatasourcename, Errors.Failed);
                        return(null);
                    }

                    //if (ds.ConnectionStatus == ConnectionState.Open)
                    //{

                    //    AddLogMessage("Success", "Create DataSource Success" + pdatasourcename, DateTime.Now, 0, null, Errors.Ok);
                    //    return ds;
                    //}
                    //else
                    //{
                    //    AddLogMessage("Failure", "Error occured in  DataSource Creation " + pdatasourcename, DateTime.Now, 0, null, Errors.Ok);
                    //    return null;

                    //}
                }
                catch (Exception ex)
                {
                    AddLogMessage("Fail", $"Error in Opening Connection (Check DLL for Connection drivers,connect string, Datasource down,Firewall, .. etc)({ex.Message})", DateTime.Now, -1, "", Errors.Failed);
                    return(null);
                }
            }
            else
            {
                AddLogMessage("Failure", "Error occured in  DataSource Creation " + pdatasourcename, DateTime.Now, 0, null, Errors.Ok);
                return(null);
            }
        }
        public void CollectionTypeMappings_OneIsNull_NotEqual()
        {
            var props1 = new ConnectionProperties
            {
                CollectionTypeMappings =
                    {
                        {"dev", new HashSet<CollectionTypeMapping>
                                    {
                                        new CollectionTypeMapping
                                            {
                                                CollectionName = "abc",
                                                CollectionType = "String"
                                            }
                                    }}
                    }
            };
            var props2 = new ConnectionProperties
            {
            };

            Assert.IsFalse(object.Equals(props1, props2));
        }
        public void CollectionTypeMappings_MappingsEqual_Equal()
        {
            var props1 = new ConnectionProperties
            {
                CollectionTypeMappings =
                    {
                        {"dev", new HashSet<CollectionTypeMapping>
                                    {
                                        new CollectionTypeMapping
                                            {
                                                CollectionName = "abc",
                                                CollectionType = "String"
                                            }
                                    }}
                    }
            };
            var props2 = new ConnectionProperties
            {
                CollectionTypeMappings =
                    {
                        {"dev", new HashSet<CollectionTypeMapping>
                                    {
                                        new CollectionTypeMapping
                                            {
                                                CollectionName = "abc",
                                                CollectionType = "String"
                                            }
                                    }}
                    }
            };

            Assert.IsTrue(object.Equals(props1, props2));
            var hash1 = props1.GetHashCode();
            var hash2 = props2.GetHashCode();
            Assert.AreEqual(hash1, hash2);
        }
        void IDisposable.Dispose()
        {
            if (!_isDisposed)
            {
                try
                {
                    GC.SuppressFinalize(this);

                    _isDisposed     = true;
                    LogPacketEvent  = null;
                    EditPacketEvent = null;
                    foreach (var pair in Nodes)
                    {
                        try
                        {
                            IDisposable d = pair.Value as IDisposable;
                            if (d != null)
                            {
                                d.Dispose();
                            }
                        }
                        catch (Exception ex)
                        {
                            Logger.SystemLogger.LogException(ex);
                        }
                    }

                    // Only dispose the meta data if this is the top level graph _or_ our meta doesn't equal our parents
                    if ((Parent == null) || (Parent.Meta != Meta))
                    {
                        foreach (dynamic value in Meta.Values)
                        {
                            try
                            {
                                IDisposable d = value as IDisposable;

                                if (d != null)
                                {
                                    d.Dispose();
                                }
                            }
                            catch (Exception ex)
                            {
                                Logger.SystemLogger.LogException(ex);
                            }
                        }

                        Meta.Clear();
                    }

                    // Only dispose the connection properties if this is the top level graph
                    if (Parent == null)
                    {
                        ((IDisposable)ConnectionProperties).Dispose();
                        ConnectionProperties.Clear();
                    }
                }
                finally
                {
                    DoGraphShutdown();
                }
            }
        }
Example #27
0
        private void propertiesToolStripMenuItem_Click(object sender, EventArgs e)
        {
            var frm = new ConnectionProperties();

            frm.ShowDialog();
        }
Example #28
0
        private void panelConnectionToolStripMenuItem_Click(object sender, EventArgs e)
        {
            //panel connection option

            if (pnlmon != null)
            {
                pnlmon.Stop();
                pnlmon.presented -= pnlmon_CardPresented;

                ConnectionPropertiesEditor connproped = pnlconnprop == null ? new ConnectionPropertiesEditor() : new ConnectionPropertiesEditor(pnlconnprop);
                if (connproped.ShowDialog(this) == DialogResult.OK)
                {
                    ConnectionProperties new_pnlconnprop = connproped.ConnectionProperties;
                    PanelMonitor         new_pnlmon      = null;
                    try
                    {
                        new_pnlmon            = new PanelMonitor(new_pnlconnprop);
                        new_pnlmon.presented += pnlmon_CardPresented;
                        new_pnlmon.Start();
                    }
                    catch (Exception ex)
                    {
                        if (new_pnlmon != null)
                        {
                            try
                            {
                                new_pnlmon.Stop();
                                new_pnlmon.presented -= pnlmon_CardPresented;
                            }
                            catch (Exception ex2) { }
                        }

                        MessageBox.Show(this, "Error connecting to panel. The settings have been reverted.");

                        pnlmon.presented += pnlmon_CardPresented;
                        pnlmon.Start();
                    }

                    pnlconnprop = new_pnlconnprop;
                    pnlmon      = new_pnlmon;
                }
                else
                {
                    pnlmon.presented += pnlmon_CardPresented;
                    pnlmon.Start();
                }

                connproped.Dispose();
            }
            else
            {
                ConnectionPropertiesEditor connproped = new ConnectionPropertiesEditor();
                if (connproped.ShowDialog(this) == DialogResult.OK)
                {
                    ConnectionProperties new_pnlconnprop = connproped.ConnectionProperties;
                    PanelMonitor         new_pnlmon      = null;
                    try
                    {
                        new_pnlmon            = new PanelMonitor(new_pnlconnprop);
                        new_pnlmon.presented += pnlmon_CardPresented;
                        new_pnlmon.Start();
                    }
                    catch (Exception ex)
                    {
                        if (new_pnlmon != null)
                        {
                            try
                            {
                                new_pnlmon.Stop();
                                new_pnlmon.presented -= pnlmon_CardPresented;
                            }
                            catch (Exception ex2) { }
                        }

                        MessageBox.Show(this, "Error connecting to panel.");
                    }

                    pnlconnprop = new_pnlconnprop;
                    pnlmon      = new_pnlmon;
                }
            }

            RefreshFormTitle();
        }
Example #29
0
        public static IEnumerable <DataEntity> QueryApi <T>(Query query, Reflector r, Dictionary <string, object> filters, string entityName, RestClient client, ConnectionProperties props)
        {
            client.Method   = HttpVerb.GET;
            client.EndPoint = buildRequestUrl(filters, entityName, props);
            client.Accept   = "application/json";
            client.PostData = "";
            if (props.HMAC == "Disabled")
            {
                client.AuthType = "Basic"; client.UserName = props.Username; client.Password = props.Password;
            }
            else
            {
                client.AuthType = "HMAC";
            }

            switch (entityName)
            {
            case EntityNames.Person:
                try
                {
                    var response = client.MakeRequest("");
                    var data     = JsonConvert.DeserializeObject <T>(response);
                    return(r.ToDataEntities(new[] { data }, query.RootEntity));
                }
                catch (RESTRequestException ex)
                {
                    Logger.Write(Logger.Severity.Error,
                                 $"Error on query for entity: {entityName}.", ex.InnerException.Message);
                    throw new InvalidExecuteQueryException($"Error on query for {entityName}: " + ex.Message);
                }

            default:
                throw new InvalidExecuteQueryException($"The {entityName} entity is not supported for query.");
            }
        }
Example #30
0
 public SendProcessor(IConnectionFactory connectionFactory, ConnectionProperties connectionProperties)
 {
     _connectionProperties = connectionProperties;
     _utils             = new Utils();
     _connectionFactory = connectionFactory;
 }
Example #31
0
 public override void Initialized()
 {
     cp = new ConnectionProperties();
     data = new byte[1024];
 }
Example #32
0
        private void Createbutton_Click(object sender, EventArgs e)
        {
            try

            {
                if (string.IsNullOrEmpty(this.layerNameTextBox.Text) || string.IsNullOrEmpty(this.localDBDriverVersionComboBox.Text) || string.IsNullOrEmpty(this.layerNameTextBox.Text))
                {
                    MessageBox.Show("Error, Please Fill all missing Fields");
                    throw new InvalidOperationException("Error, Please Fill all missing Fields");
                }
                if (DMEEditor.ConfigEditor.DataConnectionExist(layerNameTextBox.Text))
                {
                    MessageBox.Show("Error, Already there is a Data connection the Same name");
                    throw new InvalidOperationException("Error, Already there is a Data connection the Same name");
                }

                ConnectionProperties    cn      = new ConnectionProperties();
                ConnectionDriversConfig package = DMEEditor.ConfigEditor.DataDriversClasses.Where(x => x.classHandler == localDBDriverComboBox.Text).OrderByDescending(o => o.version).FirstOrDefault();
                Layer                 = (CompositeLayer)compositeQueryLayersBindingSource.Current;
                cn.CompositeLayer     = true;
                cn.ConnectionName     = layerNameTextBox.Text;
                cn.CompositeLayerName = layerNameTextBox.Text;
                cn.ConnectionName     = layerNameTextBox.Text;
                cn.DatabaseType       = package.DatasourceType;
                cn.Category           = package.DatasourceCategory;
                if (!string.IsNullOrEmpty(FileNametextBox.Text) || !string.IsNullOrEmpty(FolderSavelocationlabel.Text))
                {
                    cn.FilePath = FolderSavelocationlabel.Text;
                    cn.FileName = FileNametextBox.Text;
                }
                else
                {
                    cn.FilePath = DMEEditor.ConfigEditor.Config.Folders.Where(x => x.FolderFilesType == FolderFileTypes.DataFiles).FirstOrDefault().FolderPath;
                    cn.FileName = layerNameTextBox.Text;
                }
                if (cn.FilePath.Contains(DMEEditor.ConfigEditor.ExePath))
                {
                    cn.FilePath.Replace(DMEEditor.ConfigEditor.ExePath, ".");
                }
                cn.DriverName                = package.PackageName;
                cn.DriverVersion             = package.version;
                cn.ID                        = DMEEditor.ConfigEditor.DataConnections.Max(p => p.ID) + 1;
                cn.Category                  = DatasourceCategory.RDBMS;
                Layer.DataSourceName         = this.layerNameTextBox.Text;
                Layer.DataViewDataSourceName = this.dataViewDataSourceNameComboBox.Text;
                Layer.Entities               = new List <EntityStructure>();
                compositeQueryLayersBindingSource.EndEdit();
                DMEEditor.ConfigEditor.RemoveDataSourceEntitiesValues(Layer.DataSourceName);
                ILocalDB db = (ILocalDB)DMEEditor.CreateLocalDataSourceConnection(cn, cn.ConnectionName, package.classHandler);
                db.CreateDB();

                DMEEditor.ConfigEditor.AddDataConnection(cn);
                DMEEditor.ConfigEditor.SaveDataconnectionsValues();
                //  DMEEditor.ConfigEditor.SaveCompositeLayersValues();
                //--------------------
                try
                {
                    //  waitForm = new WaitFormFunc();
                    //  waitForm.Show(this.ParentForm);
                    CompositeLayerDataSource compositeLayerDataSource = new CompositeLayerDataSource(cn.ConnectionName, DMEEditor.Logger, DMEEditor, cn.DatabaseType, DMEEditor.ErrorObject);
                    ConnectionDriversConfig  driversConfig            = DMEEditor.Utilfunction.LinkConnection2Drivers(cn);
                    compositeLayerDataSource.Dataconnection.ConnectionProp   = cn;
                    compositeLayerDataSource.Dataconnection.DataSourceDriver = driversConfig;
                    compositeLayerDataSource.LocalDB = db;
                    // compositeLayerDataSource.Dataconnection.OpenConnection();
                    DMEEditor.OpenDataSource(cn.ConnectionName);
                    compositeLayerDataSource.Openconnection();
                    //   Visutil.treeEditor.ShowWaiting();
                    //   Visutil.treeEditor.ChangeWaitingCaption($"Getting  Composed Layer Entities Total:{compositeLayerDataSource.Entities.Count}");
                    compositeLayerDataSource.GetAllEntitiesFromDataView();
                    //    Visutil.treeEditor.HideWaiting();
                    DMEEditor.ConfigEditor.SaveCompositeLayersValues();
                    RootCompositeLayerBranch.CreateChildNodes();
                    //   waitForm.Close();
                }
                catch (Exception ex1)
                {
                    string errmsg = $"Error Creating Composite Layer for view";
                    //   waitForm.Close();
                    DMEEditor.AddLogMessage("Fail", $"{errmsg}:{ex1.Message}", DateTime.Now, 0, null, Errors.Failed);
                }

                MessageBox.Show($"Creating Composite Layer for view {branch.BranchText}");
                DMEEditor.AddLogMessage("Success", $"Creating Composite Layer for view {branch.BranchText}", DateTime.Now, 0, null, Errors.Ok);
                this.ParentForm.Close();
            }
            catch (Exception ex)
            {
                string errmsg = $"Error Creating Composite Layer for view {branch.BranchText}";

                DMEEditor.AddLogMessage("Fail", $"{errmsg}:{ex.Message}", DateTime.Now, 0, null, Errors.Failed);
                MessageBox.Show(errmsg);
            }
        }
 public DefaultCypherSessionFactory(ConnectionProperties connectionProperties)
 {
     _connectionProperties = connectionProperties;
 }
Example #34
0
 private static void WriteDBSyncScriptFile(string DDSyncSQLStr, string scriptFolder, ConnectionProperties targetConnectionProperties, string deployPath)
 {
     // Write the SQL used to synchronize to Disk
     Console.WriteLine("Writing Synchronization SQL to Disk...");
     var buildsOutputDir = System.IO.Path.Combine(scriptFolder, deployPath);
     if (!System.IO.Directory.Exists(buildsOutputDir))
         System.IO.Directory.CreateDirectory(buildsOutputDir);
     var buildsOutputFile = buildsOutputDir + string.Format("\\{0}_{1}_{2:yyyyMMdd}_{3:mmss}SyncScript.sql", targetConnectionProperties.ServerName, targetConnectionProperties.DatabaseName, DateTime.Now, DateTime.Now);
     System.IO.File.WriteAllText(buildsOutputFile, DDSyncSQLStr);
 }
Example #35
0
        public void QueryManyRowTest()
        {
            var            client  = new PhoenixClient(_credentials);
            string         connId  = GenerateRandomConnId();
            RequestOptions options = RequestOptions.GetGatewayDefaultOptions();

            // In gateway mode, url format will be https://<cluster dns name>.azurehdinsight.net/hbasephoenix<N>/
            // Requests sent to hbasephoenix0/ will be forwarded to PQS on workernode0
            options.AlternativeEndpoint = "hbasephoenix0/";
            string tableName = "Persons" + connId;

            OpenConnectionResponse  openConnResponse        = null;
            CreateStatementResponse createStatementResponse = null;

            try
            {
                // Opening connection
                pbc::MapField <string, string> info = new pbc::MapField <string, string>();
                openConnResponse = client.OpenConnectionRequestAsync(connId, info, options).Result;
                // Syncing connection
                ConnectionProperties connProperties = new ConnectionProperties
                {
                    HasAutoCommit        = true,
                    AutoCommit           = false,
                    HasReadOnly          = true,
                    ReadOnly             = false,
                    TransactionIsolation = 0,
                    Catalog = "",
                    Schema  = "",
                    IsDirty = true
                };
                client.ConnectionSyncRequestAsync(connId, connProperties, options).Wait();

                createStatementResponse = client.CreateStatementRequestAsync(connId, options).Result;
                // Running query 1
                string sql1 = "CREATE TABLE " + tableName + " (LastName varchar(255) PRIMARY KEY,FirstName varchar(255))";
                client.PrepareAndExecuteRequestAsync(connId, sql1, createStatementResponse.StatementId, long.MaxValue, int.MaxValue, options).Wait();

                // Commit statement 1
                client.CommitRequestAsync(connId, options).Wait();

                // Creating statement 2
                string          sql2            = "UPSERT INTO " + tableName + " VALUES (?,?)";
                PrepareResponse prepareResponse = client.PrepareRequestAsync(connId, sql2, long.MaxValue, options).Result;
                StatementHandle statementHandle = prepareResponse.Statement;
                // Insert 300 rows
                for (int i = 0; i < 300; i++)
                {
                    pbc::RepeatedField <TypedValue> list = new pbc.RepeatedField <TypedValue>();
                    TypedValue v1 = new TypedValue
                    {
                        StringValue = "d" + i,
                        Type        = Rep.String
                    };
                    TypedValue v2 = new TypedValue
                    {
                        StringValue = "x" + i,
                        Type        = Rep.String
                    };
                    list.Add(v1);
                    list.Add(v2);
                    ExecuteResponse executeResponse = client.ExecuteRequestAsync(statementHandle, list, long.MaxValue, true, options).Result;
                }

                // Commit statement 2
                client.CommitRequestAsync(connId, options).Wait();

                // Running query 3
                string                   sql3          = "select * from " + tableName;
                ExecuteResponse          execResponse3 = client.PrepareAndExecuteRequestAsync(connId, sql3, createStatementResponse.StatementId, long.MaxValue, int.MaxValue, options).Result;
                pbc::RepeatedField <Row> rows          = execResponse3.Results[0].FirstFrame.Rows;
                for (int i = 0; i < rows.Count; i++)
                {
                    Row row = rows[i];
                    Debug.WriteLine(row.Value[0].ScalarValue.StringValue + " " + row.Value[1].ScalarValue.StringValue);
                }
                // 100 is hard coded in server side as default firstframe size
                // In order to get remaining rows, FetchRequestAsync is used
                Assert.AreEqual(100, rows.Count);

                // Fetch remaining rows, offset is not used, simply set to 0
                // if FetchResponse.Frame.Done = true, that means all the rows fetched
                FetchResponse fetchResponse = client.FetchRequestAsync(connId, createStatementResponse.StatementId, 0, int.MaxValue, options).Result;
                Assert.AreEqual(200, fetchResponse.Frame.Rows.Count);
                Assert.AreEqual(true, fetchResponse.Frame.Done);


                // Running query 4
                string sql4 = "DROP TABLE " + tableName;
                client.PrepareAndExecuteRequestAsync(connId, sql4, createStatementResponse.StatementId, long.MaxValue, int.MaxValue, options).Wait();

                // Commit statement 4
                client.CommitRequestAsync(connId, options).Wait();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
            finally
            {
                if (createStatementResponse != null)
                {
                    client.CloseStatementRequestAsync(connId, createStatementResponse.StatementId, options).Wait();
                    createStatementResponse = null;
                }

                if (openConnResponse != null)
                {
                    client.CloseConnectionRequestAsync(connId, options).Wait();
                    openConnResponse = null;
                }
            }
        }
Example #36
0
        private static void SchemaSync(string scriptFolder, ConnectionProperties targetConnectionProperties, bool deployOnBuild, string deployPath)
        {
            using (Database sourceDatabaseScripts = new Database(), targetDatabase = new Database())
            {
                Console.WriteLine("Beginning schema sync\r\n");

                // Cleanup output dir so that script folder registration does not find duplicate Object definitions
                //CleanUpDBSyncScriptFolder(scriptFolder);

                // Establish the schema from the scripts stored in the sourceDatabaseScripts scripts folder
                // Passing in null for the database information parameter causes SQL Compare to read the
                // XML file supplied in the folder.
                Console.WriteLine("Registering Source Controlled-Path: {0}", scriptFolder);
                sourceDatabaseScripts.Register(scriptFolder, null, Options.Default);

                // Read the schema for the targetDatabase database
                Console.WriteLine("Registering Target DB: {0}", targetConnectionProperties.ServerName + " " + targetConnectionProperties.DatabaseName);
                targetDatabase.Register(targetConnectionProperties, Options.Default);

                // Compare the database against the scripts.
                // Comparing in this order makes the targetDatabase the second database
                Console.WriteLine("Performing comparison...\r\n");
                Differences sourceDatabaseScriptsVStargetDatabaseDiffs =
                    sourceDatabaseScripts.CompareWith(targetDatabase, Options.Default);

                // Select all of the differences for synchronization
                var outputStream = new StringBuilder();
                outputStream.AppendLine("/*");
                outputStream.AppendLine("Differences summary:");
                outputStream.AppendLine("Object Type       Diff   Object Name");
                outputStream.AppendLine("=============================================");
                int diffCount = 0;
                foreach (Difference difference in sourceDatabaseScriptsVStargetDatabaseDiffs)
                {
                    difference.Selected = IsIncludeObject(difference);

                    if (difference.Selected)
                    {
                        if (difference.Type != DifferenceType.Equal)
                        {
                            difference.Selected = true;
                            diffCount++;
                            outputStream.Append(difference.DatabaseObjectType.ToString().PadRight(18));
                            outputStream.Append(replaceDiffType(difference.Type.ToString()));
                            outputStream.Append(difference.Name + "\r\n");
                        }
                        else
                            difference.Selected = false;
                    }
                }
                outputStream.AppendLine("*/");

                if (diffCount == 0)
                {
                    Console.WriteLine("Schemas match!\r\n");
                    return;
                }

                // Calculate the work to do using sensible default options
                // The targetDatabase is to be updated, so the runOnTwo parameter is true
                Console.WriteLine("\r\nCalculating changes to make...\r\n");
                var work = new Work();
                work.BuildFromDifferences(sourceDatabaseScriptsVStargetDatabaseDiffs, Options.Default, true);

                // We can now access the messages and warnings
                Console.WriteLine("Messages:");

                foreach (Message message in work.Messages)
                {
                    Console.WriteLine(message.Text);
                }

                Console.WriteLine("Warnings:");

                foreach (Message message in work.Warnings)
                {
                    Console.WriteLine(message.Text);
                }

                // Disposing the execution block when it's not needed any more is important to ensure
                // that all the temporary files are cleaned up
                using (ExecutionBlock block = work.ExecutionBlock)
                {
                    // Display the SQL used to synchronize
                    Console.WriteLine("Synchronization SQL:");
                    //Console.WriteLine(block.GetString());
                    outputStream.AppendLine(block.GetString());
                    Console.WriteLine(outputStream.ToString());

                    WriteDBSyncScriptFile(outputStream.ToString(), scriptFolder, targetConnectionProperties, deployPath);

                    if (deployOnBuild)
                    {
                        // Finally, use a BlockExecutor to run the SQL against the WidgetProduction database
                        Console.WriteLine("Executing SQL...");
                        var executor = new BlockExecutor();
                        try
                        {
                            executor.ExecuteBlock(block, targetConnectionProperties.ServerName,
                                                  targetConnectionProperties.DatabaseName, false,
                                                  targetConnectionProperties.UserName, targetConnectionProperties.Password);
                            block.Dispose();
                        }
                        catch (Exception ex)
                        {
                            Console.WriteLine("Error synchronizing schema:\r\n" + ex.Message);
                            throw (ex);
                        }
                        Console.WriteLine("Schema sync complete");
                    }
                }
            }
        }
Example #37
0
        public void RowInsertWithArbitraryTimestamp()
        {
            // https://phoenix.apache.org/faq.html#Can_phoenix_work_on_tables_with_arbitrary_timestamp_as_flexible_as_HBase_API
            // The table creation time must not be later than the row insert timestamp
            // Otherwise will get table NOT FOUND exception
            // Row insert time must not be later than row query time
            // Otherwise the row will not appear in the resultset
            var            client  = new PhoenixClient(_credentials);
            string         connId  = GenerateRandomConnId();
            RequestOptions options = RequestOptions.GetGatewayDefaultOptions();

            // In gateway mode, url format will be https://<cluster dns name>.azurehdinsight.net/hbasephoenix<N>/
            // Requests sent to hbasephoenix0/ will be forwarded to PQS on workernode0
            options.AlternativeEndpoint = "hbasephoenix0/";
            string tableName = "Persons" + connId;
            OpenConnectionResponse  openConnResponse        = null;
            CreateStatementResponse createStatementResponse = null;

            try
            {
                // Opening connection
                // Set table creation time to 0
                long ts = 0;
                pbc::MapField <string, string> info = new pbc::MapField <string, string>();
                info.Add("CurrentSCN", ts.ToString());
                openConnResponse = client.OpenConnectionRequestAsync(connId, info, options).Result;
                // Syncing connection
                ConnectionProperties connProperties = new ConnectionProperties
                {
                    HasAutoCommit        = true,
                    AutoCommit           = true,
                    HasReadOnly          = true,
                    ReadOnly             = false,
                    TransactionIsolation = 0,
                    Catalog = "",
                    Schema  = "",
                    IsDirty = true
                };
                client.ConnectionSyncRequestAsync(connId, connProperties, options).Wait();

                createStatementResponse = client.CreateStatementRequestAsync(connId, options).Result;
                // Running query 1
                string sql1 = "CREATE TABLE " + tableName + " (LastName varchar(255) PRIMARY KEY,FirstName varchar(255))";
                client.PrepareAndExecuteRequestAsync(connId, sql1, createStatementResponse.StatementId, long.MaxValue, int.MaxValue, options).Wait();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
            finally
            {
                if (createStatementResponse != null)
                {
                    client.CloseStatementRequestAsync(connId, createStatementResponse.StatementId, options).Wait();
                    createStatementResponse = null;
                }

                if (openConnResponse != null)
                {
                    client.CloseConnectionRequestAsync(connId, options).Wait();
                    openConnResponse = null;
                }
            }

            // insert row with specified timestamp
            try
            {
                // Opening connection
                long ts = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds;
                pbc::MapField <string, string> info = new pbc::MapField <string, string>();
                info.Add("CurrentSCN", ts.ToString());
                openConnResponse = client.OpenConnectionRequestAsync(connId, info, options).Result;
                // Syncing connection
                ConnectionProperties connProperties = new ConnectionProperties
                {
                    HasAutoCommit        = true,
                    AutoCommit           = true,
                    HasReadOnly          = true,
                    ReadOnly             = false,
                    TransactionIsolation = 0,
                    Catalog = "",
                    Schema  = "",
                    IsDirty = true
                };
                client.ConnectionSyncRequestAsync(connId, connProperties, options).Wait();

                createStatementResponse = client.CreateStatementRequestAsync(connId, options).Result;
                // Running query 2
                string sql2 = "UPSERT INTO " + tableName + " VALUES ('d1','x1')";
                client.PrepareAndExecuteRequestAsync(connId, sql2, createStatementResponse.StatementId, long.MaxValue, int.MaxValue, options).Wait();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
            finally
            {
                if (createStatementResponse != null)
                {
                    client.CloseStatementRequestAsync(connId, createStatementResponse.StatementId, options).Wait();
                    createStatementResponse = null;
                }

                if (openConnResponse != null)
                {
                    client.CloseConnectionRequestAsync(connId, options).Wait();
                    openConnResponse = null;
                }
            }

            // query row with specified timestamp
            try
            {
                // Opening connection
                long ts = (long)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalMilliseconds;
                pbc::MapField <string, string> info = new pbc::MapField <string, string>();
                info.Add("CurrentSCN", ts.ToString());
                openConnResponse = client.OpenConnectionRequestAsync(connId, info, options).Result;
                // Syncing connection
                ConnectionProperties connProperties = new ConnectionProperties
                {
                    HasAutoCommit        = true,
                    AutoCommit           = true,
                    HasReadOnly          = true,
                    ReadOnly             = false,
                    TransactionIsolation = 0,
                    Catalog = "",
                    Schema  = "",
                    IsDirty = true
                };
                client.ConnectionSyncRequestAsync(connId, connProperties, options).Wait();

                createStatementResponse = client.CreateStatementRequestAsync(connId, options).Result;

                // Running query 3
                string          sql3          = "select count(*) from " + tableName;
                ExecuteResponse execResponse3 = client.PrepareAndExecuteRequestAsync(connId, sql3, createStatementResponse.StatementId, long.MaxValue, int.MaxValue, options).Result;
                long            count         = execResponse3.Results[0].FirstFrame.Rows[0].Value[0].ScalarValue.NumberValue;
                Assert.AreEqual(1, count);

                // Running query 4
                string sql4 = "DROP TABLE " + tableName;
                client.PrepareAndExecuteRequestAsync(connId, sql4, createStatementResponse.StatementId, long.MaxValue, int.MaxValue, options).Wait();
            }
            catch (Exception ex)
            {
                Assert.Fail(ex.Message);
            }
            finally
            {
                if (createStatementResponse != null)
                {
                    client.CloseStatementRequestAsync(connId, createStatementResponse.StatementId, options).Wait();
                    createStatementResponse = null;
                }

                if (openConnResponse != null)
                {
                    client.CloseConnectionRequestAsync(connId, options).Wait();
                    openConnResponse = null;
                }
            }
        }
        public void CollectionTypeMappings_TwoDBs_RoundTripEqual()
        {
            var prop = new ConnectionProperties
            {
                CollectionTypeMappings =
                    {
                        {"DB", new HashSet<CollectionTypeMapping>
                                   {
                                       new CollectionTypeMapping
                                           {
                                               CollectionName = "coll",
                                               CollectionType = "string"
                                           }
                                   }},
                        {"DB2", new HashSet<CollectionTypeMapping>
                                   {
                                       new CollectionTypeMapping
                                           {
                                               CollectionName = "coll2",
                                               CollectionType = "INT"
                                           }
                                   }}

                    }
            };

            //
            //Act
            //do the round trip
            var serializer = new ConnectionPropertiesSerializer();
            XElement element = new XElement("test");
            serializer.Serialize(element, prop);

            ConnectionProperties prop2 = serializer.Deserialize(element);

            //Assert
            Assert.AreEqual(prop, prop2);
        }
 public RabbitMqConnectionFactory(ConnectionProperties connectionProperties)
 {
     _connectionProperties = connectionProperties;
 }
Example #40
0
 public IScriptExecutor GetScriptExecutor(ConnectionProperties connectionProperties)
 {
     return(_scriptManager.GetExecutor(connectionProperties));
 }
Example #41
0
        static void Main(string[] args)
        {
            ConsoleColor old = Console.ForegroundColor;

            try{
                var props = new ConnectionProperties();
                using (var frm = new ConnectionDialog(props, true, Assembly.LoadFrom))
                {
                    var result = frm.ShowDialog();
                    if (result != System.Windows.Forms.DialogResult.OK)
                    {
                        return;
                    }
                }

                var cxi = new FakeConnection();
                new ConnectionPropertiesSerializer().Serialize(cxi.DriverData, props);

                var driver = new MongoDynamicDataContextDriver();


                List <Assembly> assemblies = props.AssemblyLocations.Select(Assembly.LoadFrom).ToList();
                var             code       = driver.GetStaticCodeFiles()
                                             .Concat(new string[] { driver.GenerateDynamicCode(props, assemblies, "", "driver") });
                if (props.InitializationQuery != null)
                {
                    code = code.Concat(new string[] { driver.GenerateCustomInitQuery(props.InitializationQuery, "driver") });
                }

                Console.ForegroundColor = ConsoleColor.DarkCyan;
                Console.WriteLine("------------------------------------------------");
                foreach (string s in code)
                {
                    Console.WriteLine(s);
                    Console.WriteLine("------------------------------------------------");
                }
                Console.ForegroundColor = old;

                using (var frm = new SaveFileDialog())
                {
                    var result = frm.ShowDialog();
                    if (result == DialogResult.OK)
                    {
                        using (StreamWriter writer = new StreamWriter(frm.OpenFile()))
                        {
                            foreach (string s in code)
                            {
                                writer.WriteLine(s);
                                writer.WriteLine("---------------------------------------------------");
                            }

                            writer.Flush();
                        }
                    }
                }
            }catch (Exception ex)
            {
                Console.ForegroundColor = ConsoleColor.Red;
                Console.WriteLine(ex);
            }
            finally{
                Console.ForegroundColor = old;
            }
        }
Example #42
0
 public void SetTransactionIsolation(System.Data.OleDb.OleDbConnection connection, int level)
 {
     if (this[connection] != null) {
     ConnectionProperties Properties = ((ConnectionProperties) this[connection]);
     Properties.TransactionLevel = (System.Data.IsolationLevel) level;
     } else {
     ConnectionProperties TempProp = new ConnectionProperties();
     TempProp.AutoCommit=false;
     TempProp.TransactionLevel=(System.Data.IsolationLevel) level;
     Add(connection, TempProp);
     }
 }
        private void windowConnectionThread(Object connection)
        {
            consoleWriter("Connected with window application");
            TcpClient    clienttmp = (TcpClient)connection;
            BinaryReader reader    = new BinaryReader(clienttmp.GetStream());

            while (true)
            {
                string received_data = null;
                try
                {
                    received_data = reader.ReadString();
                    JSON receivedMessage = null;
                    receivedMessage = JSON.Deserialize(received_data);
                    if (receivedMessage.Type == typeof(ConnectionProperties))
                    {
                        ConnectionProperties received_connection = receivedMessage.Value.ToObject <ConnectionProperties>();
                        if (received_connection.LocalPortTo == 0 && received_connection.VirtualPortTo == 0)
                        {
                            deleteCable(received_connection.LocalPortFrom, received_connection.VirtualPortFrom);
                            consoleWriter("Deleted connection: real port:" + received_connection.LocalPortFrom +
                                          "virtual port:" + received_connection.VirtualPortFrom);
                            continue;
                        }
                        try
                        {
                            connectToNodes(received_connection.LocalPortFrom, received_connection.VirtualPortFrom,
                                           received_connection.LocalPortTo, received_connection.VirtualPortTo);
                        }
                        catch (SocketException ex)
                        {
                            consoleWriter("Connection can't be made on port " + received_connection.LocalPortFrom);
                            return;
                        }
                    }
                    else if (receivedMessage.Type == typeof(List <ConnectionProperties>))
                    {
                        List <ConnectionProperties> received_connections = receivedMessage.Value.ToObject <List <ConnectionProperties> >();
                        foreach (ConnectionProperties received_connection in received_connections)
                        {
                            if (received_connection.LocalPortTo == 0 && received_connection.VirtualPortTo == 0)
                            {
                                deleteCable(received_connection.LocalPortFrom, received_connection.VirtualPortFrom);
                                consoleWriter("Deleted connection: real port:" + received_connection.LocalPortFrom +
                                              "virtual port:" + received_connection.VirtualPortFrom);
                                continue;
                            }
                            try
                            {
                                connectToNodes(received_connection.LocalPortFrom, received_connection.VirtualPortFrom,
                                               received_connection.LocalPortTo, received_connection.VirtualPortTo);
                            }
                            catch (SocketException ex)
                            {
                                consoleWriter("Connection can't be made on port " + received_connection.LocalPortFrom);
                                return;
                            }
                        }
                    }
                    else
                    {
                        consoleWriter(ERROR_MSG + "received from window application wrong data format.");
                    }
                }
                catch (IOException ex)
                {
                    break;
                }
            }
        }
Example #44
0
        public static async void ExecuteProcedure(DataContract dataContract)
        {
            string         connId      = Guid.NewGuid().ToString();
            RequestOptions options     = RequestOptions.GetGatewayDefaultOptions();
            var            credentials = new ClusterCredentials(new Uri("jdbc:phoenix:10.16.0.206:/hbase-unsecure"), null, null);
            var            client      = new PhoenixClient(credentials);

            // In gateway mode, PQS requests will be https://<cluster dns name>.azurehdinsight.net/hbasephoenix<N>/
            // Requests sent to hbasephoenix0/ will be forwarded to PQS on workernode0
            options.AlternativeEndpoint = "hbasephoenix0/";
            OpenConnectionResponse openConnResponse = null;
            StatementHandle        statementHandle  = null;

            try
            {
                //var info = new pbc::MapField<string, string>();
                // Opening connection
                pbc::MapField <string, string> info = new pbc::MapField <string, string>();
                openConnResponse = await client.OpenConnectionRequestAsync(connId, info, options);

                // Syncing connection
                ConnectionProperties connProperties = new ConnectionProperties
                {
                    HasAutoCommit        = true,
                    AutoCommit           = true,
                    HasReadOnly          = true,
                    ReadOnly             = false,
                    TransactionIsolation = 0,
                    Catalog = "",
                    Schema  = "",
                    IsDirty = true
                };
                await client.ConnectionSyncRequestAsync(connId, connProperties, options);

                var createStatementResponse = await client.CreateStatementRequestAsync(connId, options);

                string          sql             = "SELECT * FROM Customers";
                ExecuteResponse executeResponse = await client.PrepareAndExecuteRequestAsync(connId, sql, createStatementResponse.StatementId, long.MaxValue, int.MaxValue, options);

                pbc::RepeatedField <Row> rows = executeResponse.Results[0].FirstFrame.Rows;
                // Loop through all of the returned rows and display the first two columns
                for (int i = 0; i < rows.Count; i++)
                {
                    Row row = rows[i];
                    Console.WriteLine(row.Value[0].ScalarValue.StringValue + " " + row.Value[1].ScalarValue.StringValue);
                }

                // 100 is hard-coded on the server side as the default firstframe size
                // FetchRequestAsync is called to get any remaining rows
                Console.WriteLine("");
                Console.WriteLine($"Number of rows: {rows.Count}");

                // Fetch remaining rows, offset is not used, simply set to 0
                // When FetchResponse.Frame.Done is true, all rows were fetched
                FetchResponse fetchResponse = await client.FetchRequestAsync(connId, createStatementResponse.StatementId, 0, int.MaxValue, options);

                Console.WriteLine($"Frame row count: {fetchResponse.Frame.Rows.Count}");
                Console.WriteLine($"Fetch response is done: {fetchResponse.Frame.Done}");
                Console.WriteLine("");

                // Running query 2
                string          sql2          = "select count(*) from Customers";
                ExecuteResponse countResponse = await client.PrepareAndExecuteRequestAsync(connId, sql2, createStatementResponse.StatementId, long.MaxValue, int.MaxValue, options);

                long count = countResponse.Results[0].FirstFrame.Rows[0].Value[0].ScalarValue.NumberValue;

                Console.WriteLine($"Total customer records: {count}");
                Console.WriteLine("");

                // Running query 3
                string          sql3            = "select StateProvince, count(*) as Number from Customers group by StateProvince order by Number desc";
                ExecuteResponse groupByResponse = await client.PrepareAndExecuteRequestAsync(connId, sql3, createStatementResponse.StatementId, long.MaxValue, int.MaxValue, options);

                pbc::RepeatedField <Row> stateRows = groupByResponse.Results[0].FirstFrame.Rows;
                for (int i = 0; i < stateRows.Count; i++)
                {
                    Row row = stateRows[i];
                    Console.WriteLine(row.Value[0].ScalarValue.StringValue + ": " + row.Value[1].ScalarValue.NumberValue);
                }
            }
            catch (Exception ex)
            {
            }
            finally
            {
                if (statementHandle != null)
                {
                    await client.CloseStatementRequestAsync(connId, statementHandle.Id, options);

                    statementHandle = null;
                }
                if (openConnResponse != null)
                {
                    await client.CloseConnectionRequestAsync(connId, options);

                    openConnResponse = null;
                }
            }
        }
Example #45
0
 /// <summary></summary>
 internal Storage()
 {
     ConnectionProperties = new ConnectionProperties();
 }
Example #46
0
 /// <summary>
 /// Constructs an instance of <see cref="CodeGenerationContext"/>.
 /// </summary>
 /// <param name="edmx">The string for the edmx.</param>
 /// <param name="namespacePrefix">The namespacePrefix is used as the only namespace in generated code
 /// when there's only one schema in edm model, and as a prefix for the namespace from the model with multiple
 /// schemas. If this argument is null, the namespaces from the model are used for all types.</param>
 /// <param name="properties"></param>
 private CodeGenerationContext(string edmx, string namespacePrefix, ConnectionProperties properties)
 {
     Edmx             = XElement.Parse(edmx);
     _namespacePrefix = namespacePrefix;
     _properties      = properties;
 }
Example #47
0
        private static string buildRequestUrl(Dictionary <string, object> filters, string entityName, ConnectionProperties props)
        {
            var uri          = new UriBuilder(props.BaseUrl);
            var queryBuilder = HttpUtility.ParseQueryString(string.Empty);

            foreach (var kvp in filters.ToDictionary(k => k.Key, k => k.Value.ToString()).ToArray())
            {
                queryBuilder.Add(kvp.Key, kvp.Value);
            }

            switch (entityName)
            {
            case EntityNames.Person:
                uri.Path = "/customers/" + props.CustomerId + "/people/" + queryBuilder.Get("peopleId");
                queryBuilder.Remove("peopleId");     //removes URI param from query string
                uri.Query = queryBuilder.ToString();
                return(uri.ToString());

            case "something else":
                uri.Path  = props.BaseUrl + "/something/" + props.CustomerId + "/else";
                uri.Query = queryBuilder.ToString();
                return(uri.ToString());

            default:
                throw new InvalidExecuteQueryException($"The {entityName} entity is not supported for query.");
            }
        }
 protected override void ParseConnectionStr(ConnectionProperties properties)
 {
     txtFile.Text = properties.TryGetValue("data source");
 }
        public async Task <ActionResult <ConnectionProperties> > Update([FromBody] ConnectionProperties connection)
        {
            connection = await _work.ConnectionPropertiesRepository.Update(connection);

            return(connection);
        }
Example #50
0
 /// <summary>
 /// Constructs an instance of <see cref="CodeGenerationContext"/>.
 /// </summary>
 /// <param name="metadataUri">The Uri to the metadata document. The supported scheme are File, http and https.</param>
 /// <param name="namespacePrefix">The namespacePrefix is used as the only namespace in generated code
 /// when there's only one schema in edm model, and as a prefix for the namespace from the model with multiple
 /// schemas. If this argument is null, the namespaces from the model are used for all types.</param>
 /// <param name="properties"></param>
 public CodeGenerationContext(Uri metadataUri, string namespacePrefix, ConnectionProperties properties)
     : this(GetEdmxStringFromMetadataPath(metadataUri, properties), namespacePrefix, properties)
 {
 }
Example #51
0
 public Configuration(string uri, string namespacePrefix, ConnectionProperties properties)
 {
     MetadataDocumentUri = uri;
     NamespacePrefix     = namespacePrefix;
     Properties          = properties;
 }
        public void CollectionTypeMappings_EmptyDB_RoundTripEqual()
        {
            var prop = new ConnectionProperties
            {
                CollectionTypeMappings =
                    {
                        {"DB", new HashSet<CollectionTypeMapping>()}
                    }
            };

            //
            //Act
            //do the round trip
            var serializer = new ConnectionPropertiesSerializer();
            XElement element = new XElement("test");
            serializer.Serialize(element, prop);

            ConnectionProperties prop2 = serializer.Deserialize(element);

            //Assert
            Assert.AreEqual(prop, prop2);
        }
Example #53
0
			public void SetTransactionIsolation(System.Data.OleDb.OleDbConnection connection, int level)
			{
				ConnectionProperties Properties;
				if(level == (int)System.Data.IsolationLevel.ReadCommitted)
					SetAutoCommit(connection, false);
				else
					if(level == (int)System.Data.IsolationLevel.ReadUncommitted)
					SetAutoCommit(connection, false);
				else
					if(level == (int)System.Data.IsolationLevel.RepeatableRead)
					SetAutoCommit(connection, false);
				else
					if(level == (int)System.Data.IsolationLevel.Serializable)
					SetAutoCommit(connection, false);

				if (this[connection] != null)
				{
					Properties =((ConnectionProperties)this[connection]);					
					Properties.TransactionLevel = (System.Data.IsolationLevel)level;
				}
				else
				{	
					Properties = new ConnectionProperties();
					Properties.AutoCommit = true;    					    
					Properties.TransactionLevel = (System.Data.IsolationLevel)level;	
					Add(connection, Properties);
				}
			}
Example #54
0
 public PanelMonitor(ConnectionProperties connprop)
 {
     this.connprop = connprop;
 }
Example #55
0
 public Connection(int from, int to, ConnectionProperties connectionProperties)
 {
     From = from;
     To = to;
     Weight = connectionProperties.WeightGenerator.Generate();
 }
        public void ConnectionString_RoundTrip_Equal()
        {
            var prop = new ConnectionProperties
                           {
                               ConnectionString = "ABC"
                           };

            //
            //Act
            //do the round trip
            var serializer = new ConnectionPropertiesSerializer();
            XElement element = new XElement("test");
            serializer.Serialize(element, prop);

            ConnectionProperties prop2 = serializer.Deserialize(element);

            //Assert
            Assert.AreEqual(prop, prop2);
        }
Example #57
0
        public void Test()
        {
            var comparisonConfiguration = new ComparisonConfiguration
            {
                SourceServerName = "SomeServerNameOrIp",
                SoureDatabaseName = "SomeDatabaseName",
                SourcePassword = "******",
                SourceUserName = "******",
                TargetServerName = "SomeServerNameOrIp",
                TargetDatabasName = "SomeDatabaseName",
                TargetPassword = "******",
                TargetUserName = "******"
            };

            using (Database stagingDb = new Database(), productionDb = new Database())
            {
                var sourceConnectionProperties =
                    new ConnectionProperties(comparisonConfiguration.SourceServerName,
                        comparisonConfiguration.SoureDatabaseName, comparisonConfiguration.SourceUserName,
                        comparisonConfiguration.SourcePassword);

                var targetConnectionProperties = new ConnectionProperties(
                    comparisonConfiguration.TargetServerName, comparisonConfiguration.TargetDatabasName,
                    comparisonConfiguration.TargetUserName, comparisonConfiguration.TargetPassword);

                // Connect to the two databases and read the schema
                try
                {
                    Console.WriteLine("Registering database " + sourceConnectionProperties.DatabaseName);
                    stagingDb.Register(sourceConnectionProperties, Options.Default);
                }
                catch (SqlException e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine(@"
            Cannot connect to database '{0}' on server '{1}'. The most common causes of this error are:
            o The sample databases are not installed
            o ServerName not set to the location of the target database
            o For sql server authentication, username and password incorrect or not supplied in ConnectionProperties constructor
            o Remote connections not enabled", sourceConnectionProperties.DatabaseName,
                        sourceConnectionProperties.ServerName);
                    return;
                }
                try
                {
                    Console.WriteLine("Registering database " + targetConnectionProperties.DatabaseName);
                    productionDb.Register(targetConnectionProperties, Options.Default);
                }
                catch (SqlException e)
                {
                    Console.WriteLine(e.Message);
                    Console.WriteLine(@"
            Cannot connect to database '{0}' on server '{1}'. The most common causes of this error are:
            o The sample databases are not installed
            o ServerName not set to the location of the target database
            o For sql server authentication, username and password incorrect or not supplied in ConnectionProperties constructor
            o Remote connections not enabled", targetConnectionProperties.DatabaseName,
                        targetConnectionProperties.ServerName);
                    return;
                }

                // Compare WidgetStaging against WidgetProduction
                Differences stagingVsProduction = stagingDb.CompareWith(productionDb, Options.Default);
                Log4NetLogger.LogEntry(GetType(), "SqlCompareResult",
                    string.Format("Total Differences = {0}", stagingVsProduction.Count(x => x.Type != DifferenceType.Equal)), LoggerLevel.Info);
                // Display the results on the console
                foreach (Difference difference in stagingVsProduction)
                {
                    if (difference.Type != DifferenceType.Equal)
                    {
                        Log4NetLogger.LogEntry(GetType(), "SqlCompareResult",
                            string.Format("{0} {1} {2}", difference.Type, difference.DatabaseObjectType, difference.Name),
                            LoggerLevel.Info);
                    }
                }
                Log4NetLogger.LogEntry(GetType(), "SqlCompareResult", string.Format("Finished writing differences"),
                    LoggerLevel.Info);
            }
        }
        public void CustomSerializers_RoundTrip_Equal()
        {
            var prop = new ConnectionProperties
            {
                CustomSerializers =
                    {
                        {"abc", "Def"}
                    }
            };

            //
            //Act
            //do the round trip
            var serializer = new ConnectionPropertiesSerializer();
            XElement element = new XElement("test");
            serializer.Serialize(element, prop);

            ConnectionProperties prop2 = serializer.Deserialize(element);

            //Assert
            Assert.AreEqual(prop, prop2);
        }
 public void ConnectJnior()
 {
     ConnectionProperties cp = new ConnectionProperties(JNIOR_IP, JNIOR_PORT, 1000, 30);
     jnior_.ConnectAsync(cp);
 }
        public void SelectedDB_RoundTrip_Equal()
        {
            var prop = new ConnectionProperties
            {
                SelectedDatabase = "abcdef"
            };

            //
            //Act
            //do the round trip
            var serializer = new ConnectionPropertiesSerializer();
            XElement element = new XElement("test");
            serializer.Serialize(element, prop);

            ConnectionProperties prop2 = serializer.Deserialize(element);

            //Assert
            Assert.AreEqual(prop, prop2);
        }