Ejemplo n.º 1
0
        private void save_config_button_Click(object sender, EventArgs e)
        {
            toolstripStatusLabelValue = "Try to save configuration ...";

            #region Loki - Create MySQL Connection String

            var sb = new MySqlConnectionStringBuilder();
            //Host
            if (String.IsNullOrEmpty(mysql_host_textbox.Text))
            {
                addWrongValueErrorHandler(mysql_host_textbox,
                                          "The value of \"Server Address\" in \"MySQL Database settings\" is not set.");
                return;
            }
            sb.Server = mysql_host_textbox.Text;

            //Port
            if (String.IsNullOrEmpty(mysql_port_textbox.Text))
            {
                addWrongValueErrorHandler(mysql_port_textbox,
                                          "The value of \"Port\" in \"MySQL Database settings\" is not allowed.");
                return;
            }
            sb.Port = Convert.ToUInt16(mysql_port_textbox.Text);

            //Database Name
            if (String.IsNullOrEmpty(mysql_database_name_textbox.Text))
            {
                addWrongValueErrorHandler(mysql_database_name_textbox,
                                          "The value of \"Database Name\" in \"MySQL Database settings\" is not set.");
                return;
            }
            sb.Database = mysql_database_name_textbox.Text;

            //Username
            if (String.IsNullOrEmpty(mysql_username_textbox.Text))
            {
                addWrongValueErrorHandler(mysql_username_textbox,
                                          "The value of \"Username\" in \"MySQL Database settings\" is not set.");
                return;
            }
            sb.UserID = mysql_username_textbox.Text;

            //Password
            sb.Password = mysql_password_textbox.Text;

            //Treat tiny as boolean
            sb.TreatTinyAsBoolean = false;

            //Set generated connection string
            var t = sb.ConnectionString;

            //Just for fun: Test the connection
            // mysql_test_button_Click(null, null);

            #endregion

            ConnectionStringService.SetString(sb.UserID, sb.Password, sb.Server, sb.Database, sb.Port);
            Close();
        }
Ejemplo n.º 2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc();
            services.AddScoped <FileStore, FileStore>();
            services.AddScoped <SearchSQLProductService, SearchSQLProductService>();
            services.AddScoped <SearchBlobService, SearchBlobService>();
            services.AddScoped <ConnectionStringService, ConnectionStringService>();

            var csService = ConnectionStringService.GetInstanceAsync().Result;

            services.AddSingleton <ConnectionStringService>(csService);

            //var connection = @"Server=mysqlvmlabel.westeurope.cloudapp.azure.com,1433;Database=AdventureWorks2012;user id=volha_viktarava;password=123456qwerty!@;Trusted_Connection=True;ConnectRetryCount=0";
            //var connection = @"data source=mysqlvmlabel.westeurope.cloudapp.azure.com,1433;initial catalog=AdventureWorks2012;integrated security=false;user id=volha_viktarava;password=123456qwerty!@;MultipleActiveResultSets=True;";
            //var connection =
            //  @"data source=localhost;initial catalog = AdventureWorks2012; persist security info = True;Integrated Security = SSPI;";

            // personal subscription
            //var connection =
            //  @"Server= adventureworks2server.database.windows.net,1433;Initial Catalog=AdventureWorks2;Persist Security Info=False;User ID=volha_viktarava;Password=123456qwerty!@;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";

            //// epam subscription
            //var connection =
            //  @"Server=tcp:adventureworksserver12.database.windows.net,1433;Initial Catalog=AdventureWorks;Persist Security Info=False;User ID=volha_viktarava;Password=123456qwerty!@;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";

            //var conn =
            //  @"Server=tcp:adventure-worksserver.database.windows.net,1433;Initial Catalog=AdventureWorks;Persist Security Info=False;User ID=volha-viktarava;Password=123456qwerty!@;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;";
            services.AddDbContext <AdventureWorksDbContext>(options => options.UseSqlServer(csService.Message));

            services.AddSwaggerGen(c => c.SwaggerDoc("v1", new Info {
                Title = "My API", Version = "v1"
            }));
        }
        private string GetConnectionString(string odsConnectionStringTemplate, string odsInstanceName, ApiMode apiMode)
        {
            var mockConnectionStringBuilderAdapterFactory = new Mock <IConnectionStringBuilderAdapterFactory>();

            mockConnectionStringBuilderAdapterFactory.Setup(x => x.Get()).Returns(new SqlConnectionStringBuilderAdapter());
            var service = new ConnectionStringService(GetConnectionStringsAccessor(odsConnectionStringTemplate), mockConnectionStringBuilderAdapterFactory.Object);

            return(service.GetConnectionString(odsInstanceName, apiMode));
        }
Ejemplo n.º 4
0
        public RegistrationTests(DatabaseFixture fixture)
        {
            this.connectionStringService = new ConnectionStringService(ConnectionString.Value);
            this.fixture = fixture;

            UserHelper.CleanByUserName(RegistrationTestUser1);
            UserHelper.CleanByUserName(RegistrationTestUser2);

            this.connectionForTest = new NpgsqlConnection(ConnectionString.Value);
        }
Ejemplo n.º 5
0
        public void TestUpdatePassword()
        {
            ConnectionStringService connectionStringService
                = new ConnectionStringService(ConnectionString.Value);

            SecurityService securityService = new SecurityService();

            UserService userService = new UserService(connectionStringService, securityService,
                                                      IOptionsHelper.Get());

            var response = userService.UpdatePassword("992296994", securityService.HashUserNameAndPassword("992296994", "Deeps@123"));

            Assert.True(response.IsSuccess);
        }
Ejemplo n.º 6
0
        private bool ProbeSpectrumDatabase()
        {
            string     spectrumDatabaseString = ConnectionStringService.GetConnectionString("Spectrum");
            SQLControl sql = new SQLControl(spectrumDatabaseString);

            //sql.AddParam("@jobNumber", _jobNumber);

            //sql.AddParam("@costType", "L");
            sql.ExecQuery("SELECT * FROM JC_TRANSACTION_HISTORY_MC WHERE Job_Number = '   2190302'");
            if (sql.HasException())
            {
                return(false);
            }
            else
            {
                return(true);
            }
        }
Ejemplo n.º 7
0
        public void TestAuthenticate()
        {
            ConnectionStringService connectionStringService
                = new ConnectionStringService(ConnectionString.Value);

            SecurityService securityService = new SecurityService();

            UserService userService = new UserService(connectionStringService, securityService,
                                                      IOptionsHelper.Get());

            var response = userService.Authenticate("mladmin", "ML@Vkt0rY");

            Assert.True(response.IsSuccess);
            Assert.NotNull(response.Data);
            Assert.NotNull(response.Data.user.token);
            Assert.True(response.Data.user.token.Length > 0);

            //no need to test the saved user
            //var savedUser = userService.Get(user.id);
            //Assert.Equal(savedUser.token, user.token);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// Returns true if the job number is found in the estimating database.  Only one estimate record is allowed per job number.
        /// </summary>
        /// <param name="jobNumber"></param>
        /// <returns></returns>
        public bool IsDuplicateJobNumber(string jobNumber)
        {
            using (SQLControl sql = new SQLControl(ConnectionStringService.GetConnectionString("Estimate")))
            {
                sql.AddParam("@jobNumber", jobNumber);
                sql.ExecQuery("SELECT * FROM EstimateHeader WHERE JobNumber = @jobNumber");

                if (sql.HasException())
                {
                    throw new Exception("Error in SQLControl class while attempting to detect duplicate job numbers.");
                }

                if (sql.DBDT.Rows.Count == 0)
                {
                    return(false);
                }
                else
                {
                    return(true);
                }
            };
        }