Exemplo n.º 1
0
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddSwaggerGen(c => { c.SwaggerDoc("v1", new Info {
                    Title = "API"
                }); });

            services.CreateAutoMapper();

            services.AddMvc()
            .AddApplicationPart(typeof(ApiController).Assembly)
            .SetCompatibilityVersion(CompatibilityVersion.Version_2_2);

            var dbHelper = new DbConnectionHelper(Configuration);

            services
            .AddEntityFrameworkNpgsql()
            .AddDbContext <CompositeKeyContext>(options =>
            {
                options.UseNpgsql(dbHelper.GetConnectionString(),
                                  b =>
                {
                    b.MigrationsAssembly(typeof(CompositeKeyContext).Assembly.GetName().Name);
                    b.ProvideClientCertificatesCallback(dbHelper.ProvideClientCertificatesCallback);
                    b.RemoteCertificateValidationCallback(
                        dbHelper.RemoteCertificateValidationCallback);
                });
                options.UseOpenIddict();
            })
            .BuildServiceProvider();
        }
Exemplo n.º 2
0
        public bool TransactionOPEntitysCommit(Func <IDbConnection, IDbTransaction, bool> fun)
        {
            try
            {
                using (var cn = DbConnectionHelper.CreateConnection())
                {
                    cn.Open();


                    IDbTransaction transaction = cn.BeginTransaction();

                    if (fun(cn, transaction))
                    {
                        transaction.Commit();
                    }

                    cn.Close();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.Message);
                return(false);
            }


            return(true);
        }
Exemplo n.º 3
0
 public string GetEntityViewJson <TV>(string sql, object param = null)
 {
     try
     {
         using (var cn = DbConnectionHelper.CreateConnection())
         {
             cn.Open();
             var itemList = cn.Query <TV>(sql, param).ToList();
             cn.Close();
             if (itemList != null)
             {
                 return(JsonUtil.toJson(new { Msg = true, Content = JsonUtil.toJson(itemList) }));
             }
             else
             {
                 return(JsonUtil.toJson(new { Msg = false }));
             }
         }
     }
     catch (Exception ex)
     {
         Debug.WriteLine(ex.Message);
         return(JsonUtil.toJson(new { Msg = false }));
     }
 }
Exemplo n.º 4
0
        public void GetProviderTest()
        {
            DbConnectionHelper helper   = new DbConnectionHelper();
            string             provider = helper.GetProvider("Odbc Data Provider");

            Assert.IsNotNull(provider);
        }
Exemplo n.º 5
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            var isConnected = false;

            SaveAppConfig();

            // tes koneksi ke server
            using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0)))
            {
                IDbConnectionHelper dbConn = new DbConnectionHelper();
                isConnected = dbConn.IsOpenConnection();
            }

            if (!isConnected)
            {
                var msg = "Maaf koneksi ke database gagal !!!\n\n" +
                          "Disarankan untuk menginstall OpenRetail di 'Drive D'.\n" +
                          "Silahkan uninstall dulu OpenRetailnya, kemudian install lagi di 'Drive D'.";

                MsgHelper.MsgError(msg);
                return;
            }

            using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0)))
            {
                IPenggunaBll penggunaBll = new PenggunaBll(_log);

                var pass    = CryptoHelper.GetMD5Hash(txtPassword.Text, MainProgram.securityCode);
                var isLogin = penggunaBll.IsValidPengguna(txtUserName.Text, pass);

                if (isLogin)
                {
                    UpgradeDatabase(DatabaseVersionHelper.DatabaseVersion);

                    log4net.GlobalContext.Properties["UserName"] = txtUserName.Text;
                    MainProgram.pengguna = penggunaBll.GetByID(txtUserName.Text);

                    SetProfil();
                    SetPengaturanUmum();
                    SetPengaturanBarcode();
                    SetSettingPort();
                    SetSettingCustomerDisplay();
                    LoadKabupaten();
                    LoadWilayah();

                    if (MainProgram.pengaturanUmum.is_show_minimal_stok)
                    {
                        LoadInfoMinimalStokProduk();
                    }

                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MsgHelper.MsgWarning("User name atau password salah !!!");
                    txtUserName.Focus();
                }
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// Обновить настройки справочников для выбранной БД.
        /// </summary>
        private void UpdateNsiCollection()
        {
            try
            {
                if (SelectedDb == null)
                {
                    return;
                }

                HourGlass.Enable = true;

                NsiModel = null;

                string connectionString = DbConnectionHelper.BuildConnection(SelectedDb.DbName);

                NsiModel = new NsiModel(connectionString);

                NsiModel.GM_NSIReferenceSet.Load();
                //Все справочники
                NsiCollection = NsiModel.GM_NSIReferenceSet.Local;
            }
            catch (Exception)
            {
                //TODO log
            }
            finally
            {
                HourGlass.Enable = false;
            }
        }
Exemplo n.º 7
0
 public async Task <int> UpdateSocialProgramTresuryValidationAsync(string id, string tresuryValidated)
 {
     return(await DbConnectionHelper.ExecuteAsync(_conString, _conType, SP_UpdateSocialProgramsTresuryValidation, new
     {
         batch_id = id,
         tresury_validated = tresuryValidated
     }, true));
 }
Exemplo n.º 8
0
        public void GetListProvidersTest()
        {
            DbConnectionHelper   helper    = new DbConnectionHelper();
            IEnumerable <string> providers = helper.GetListProviders();

            Assert.IsNotNull(providers);
            Assert.AreEqual("Odbc Data Provider", providers.ElementAt(0));
        }
Exemplo n.º 9
0
        public void GetConnectionStringTest()
        {
            DbSource           dbSource   = new DbSource();
            DbConnectionHelper helper     = new DbConnectionHelper(dbSource);
            string             connection = helper.GetConnectionString("Odbc Data Provider");

            Assert.IsNotNull(connection);
        }
Exemplo n.º 10
0
        private void button1_Click(object sender, RoutedEventArgs e)
        {
            MessageBox.Show(DbConnectionHelper.GetConnection().ConnectionString.ToString(), "");
            List <string> a = new List <string>();

            a.Add("insert into  FactSpvas(pr,qty,codeid,dateid) select 1,6,3,4");
            SqlHelper.ExecuteTransaction(a);
        }
Exemplo n.º 11
0
 public async Task <int> UpdateSocialProgramRulesAsync(string id, SocialProgramModel socialProgram)
 {
     return(await DbConnectionHelper.ExecuteAsync(_conString, _conType, SP_UpdateSocialProgramsRules, new
     {
         id,
         socialProgram.rules_break,
         socialProgram.batch_id
     }, true));
 }
 public ConfigurationWindowViewModel(SourceTypeEnum type)
 {
     base.DisplayName     = Resources.ConfigurationWindowViewModel_DisplayName;
     _source              = new Source(type);
     _configuration       = new DbConnectionHelper();
     ListProviders        = _configuration.GetListProviders();
     _connectionMessenger = new NotificationConnectionMessenger();
     CreateCommand        = new ActionCommand(Create);
 }
Exemplo n.º 13
0
        public void CreateConnectionTest()
        {
            DbSource dbSource = new DbSource();

            dbSource.Provider = "SqlClient Data Provider";
            DbConnectionHelper helper     = new DbConnectionHelper(dbSource);
            DbConnection       connection = helper.CreateConnection();

            Assert.IsNotNull(connection);
        }
Exemplo n.º 14
0
        public void GetStateConnectionTest()
        {
            DbSource dbSource = new DbSource();

            dbSource.Provider = "SqlClient Data Provider";
            dbSource.DataBase = "PatientServices";
            DbConnectionHelper helper = new DbConnectionHelper(dbSource);
            bool isConection          = helper.GetStateConnection();

            Assert.IsNotNull(isConection);
        }
Exemplo n.º 15
0
        private void btnLogin_Click(object sender, EventArgs e)
        {
            var isConnected = false;

            SaveAppConfig();

            // tes koneksi ke server
            using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0)))
            {
                IDbConnectionHelper dbConn = new DbConnectionHelper();
                isConnected = dbConn.IsOpenConnection();
            }

            if (!isConnected)
            {
                var msg = "Maaf koneksi ke server database gagal !!!\n" +
                          "Silahkan cek koneksi jaringan Anda.";
                MsgHelper.MsgError(msg);
                return;
            }

            using (new StCursor(Cursors.WaitCursor, new TimeSpan(0, 0, 0, 0)))
            {
                IPenggunaBll penggunaBll = new PenggunaBll(_log);

                var pass    = CryptoHelper.GetMD5Hash(txtPassword.Text, MainProgram.securityCode);
                var isLogin = penggunaBll.IsValidPengguna(txtUserName.Text, pass);

                if (isLogin)
                {
                    log4net.GlobalContext.Properties["UserName"] = txtUserName.Text;
                    MainProgram.pengguna = penggunaBll.GetByID(txtUserName.Text);

                    SetProfil();

                    //TODO: fix me, aktifkan jika module report sudah selesai

                    /*
                     * if (!Utils.IsRunningUnderIDE())
                     * {
                     *  LoadCrystalReportLib();
                     * }*/

                    this.DialogResult = DialogResult.OK;
                    this.Close();
                }
                else
                {
                    MsgHelper.MsgWarning("User name atau password salah !!!");
                    txtUserName.Focus();
                }
            }
        }
        public static int DeleteVoucherTemplate(tVoucherTemplate templates)
        {
            int rowsAdded;

            using (IDbConnection connection = DbConnectionHelper.GetConnection())
            {
                var query = SqlQueryHelper.GetDeleteQuery <tVoucherTemplate>();

                rowsAdded = connection.Execute(query, templates);
            }

            return(rowsAdded);
        }
        public static IEnumerable <tAccountingYear> GetAllAccountingYear()
        {
            IEnumerable <tAccountingYear> tAccountingYears;

            using (IDbConnection connection = DbConnectionHelper.GetConnection())
            {
                const string query = "SELECT * FROM tAccountingYear A ORDER BY A.AccountYearId";

                tAccountingYears = connection.Query <tAccountingYear>(query);
            }

            return(tAccountingYears);
        }
        public static IEnumerable <tDebtorGroup> GetAllDebtorGroups()
        {
            IEnumerable <tDebtorGroup> debtorGroups;

            using (IDbConnection connection = DbConnectionHelper.GetConnection())
            {
                string query = "SELECT * FROM tDebtorGroup C ORDER BY C.DebtorGroupId";

                debtorGroups = connection.Query <tDebtorGroup>(query);
            }

            return(debtorGroups);
        }
        public static IEnumerable <tCurrencyRate> GetAllCurrencieRates()
        {
            IEnumerable <tCurrencyRate> currencyRates;

            using (IDbConnection connection = DbConnectionHelper.GetConnection())
            {
                string query = "SELECT * FROM tCurrencyRate C ORDER BY C.Id";

                currencyRates = connection.Query <tCurrencyRate>(query);
            }

            return(currencyRates);
        }
        public static IEnumerable <tChartOfAccount> GetAllChartOfAccount()
        {
            IEnumerable <tChartOfAccount> accounts;

            using (IDbConnection connection = DbConnectionHelper.GetConnection())
            {
                const string query = "SELECT * FROM tChartOfAccount C ORDER BY C.AccountCode";

                accounts = connection.Query <tChartOfAccount>(query);
            }

            return(accounts);
        }
        public static IEnumerable <tAccountingTransactionTemp> GetAllUnpostedVoucher()
        {
            IEnumerable <tAccountingTransactionTemp> entries;

            using (IDbConnection connection = DbConnectionHelper.GetConnection())
            {
                string query = SqlQueryHelper.GetSelectQuery <tAccountingTransactionTemp>();

                entries = connection.Query <tAccountingTransactionTemp>(query);
            }

            return(entries);
        }
        public static IEnumerable <tVoucherTemplate> GetAllVoucherTemplates()
        {
            IEnumerable <tVoucherTemplate> templates;

            using (IDbConnection connection = DbConnectionHelper.GetConnection())
            {
                string query = SqlQueryHelper.GetSelectQuery <tVoucherTemplate>();

                templates = connection.Query <tVoucherTemplate>(query);
            }

            return(templates);
        }
Exemplo n.º 23
0
        public DatabaseService()
        {
            Configuration = new ConfigurationBuilder()
                            .AddJsonFile("connectionStrings.Local.json")
                            .Build();

            WebConfiguration = new TestWebConfiguration
            {
                SqlConnectionString = Configuration.GetConnectionString("SqlConnectionStringTest")
            };

            DbConnectionHelper = new DbConnectionHelper(WebConfiguration, new TestHostingEnvironment());
        }
        public static IEnumerable <tTaxSetup> GetAllTaxes()
        {
            IEnumerable <tTaxSetup> tTaxs;

            using (IDbConnection connection = DbConnectionHelper.GetConnection())
            {
                const string query = "SELECT * FROM tTaxSetup C ORDER BY C.TaxCode";

                tTaxs = connection.Query <tTaxSetup>(query);
            }

            return(tTaxs);
        }
 public ConfigurationWindowViewModel(Source source)
 {
     base.DisplayName    = Resources.ConfigurationWindowViewModel_DisplayName;
     _previousSourceData = source;
     _source             = new Source(source.TypeEnum)
     {
         Description = source.Description, Name = source.Name, Parameters = source.Parameters
     };
     _configuration       = new DbConnectionHelper();
     ListProviders        = _configuration.GetListProviders();
     _connectionMessenger = new NotificationConnectionMessenger();
     CreateCommand        = new ActionCommand(Update);
 }
        public static int DeleteLastVoucherInformation(tLastVoucherInformation lastVoucher)
        {
            int rowsAdded;

            var query = "DELETE FROM tLastVoucherInformation";

            using (IDbConnection connection = DbConnectionHelper.GetConnection())
            {
                rowsAdded = connection.Execute(query, lastVoucher);
            }

            return(rowsAdded);
        }
        public static int AddLastVoucherInformation(tLastVoucherInformation lastVoucher)
        {
            int rowsAdded;

            using (IDbConnection connection = DbConnectionHelper.GetConnection())
            {
                var query = SqlQueryHelper.GetInsertQuery <tLastVoucherInformation>();

                rowsAdded = connection.Execute(query, lastVoucher);
            }

            return(rowsAdded);
        }
        public static int DeleteUnpostedVoucher(tAccountingTransactionTemp transaction)
        {
            int rowsAdded;

            using (IDbConnection connection = DbConnectionHelper.GetConnection())
            {
                var query = SqlQueryHelper.GetDeleteQuery <tAccountingTransactionTemp>();

                rowsAdded = connection.Execute(query, transaction);
            }

            return(rowsAdded);
        }
        public static int DeleteAccount(tChartOfAccount account)
        {
            int rowsAdded;

            using (IDbConnection connection = DbConnectionHelper.GetConnection())
            {
                var query =
                    new StringBuilder("DELETE FROM tChartOfAccount WHERE CompanyID = @CompanyID and AccountCode=@AccountCode");

                rowsAdded = connection.Execute(query.ToString(), account);
            }

            return(rowsAdded);
        }
        public static tAccountingTransactionTemp GetUnpostedVoucherByNo(int voucherNo)
        {
            tAccountingTransactionTemp templates;
            string query = "SELECT * FROM tAccountingTransactionTemp WHERE VoucherNo = @VoucherNo";

            using (IDbConnection connection = DbConnectionHelper.GetConnection())
            {
                templates = connection.Query <tAccountingTransactionTemp>(query, new tAccountingTransactionTemp {
                    VoucherNo = voucherNo
                }).FirstOrDefault();
            }

            return(templates);
        }