Git Product home page Git Product logo

dappercontext's Introduction

Hi there, I'm Wesley ๐Ÿ‘‹

I'm a coding architect at Xebia based in Antwerp, Belgium. Most of my work involves .NET / C# and Azure, creating ASP.NET Core web apps and APIs or cloud-native solutions.

Connecting with me ๐Ÿ”—

You can find me on various social platforms, the one I use the most are:

If you're interested in sessions or workshops that I could deliver at your company or conference, have a look at my Sessionize page.

I can also be found on other platforms like Mastodon, Bluesky Social and Threads, but as long as I can't crosspost, the ones above are your safest bets.

๐Ÿ’— Sponsor me

You can sponsor me using GitHub sponsors ๐Ÿ™‚

dappercontext's People

Contributors

wcabus avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

dappercontext's Issues

endless loop exception from dispose method

Hi
When call the below function it goes endless loop.

May i know what did i wrong on this.

Thanks,
Shiva

try
            {
                DboCampaign _DboCampaign;
               
                using (var context = CreatePartnerContext())
                {
                    using (var scope = context.CreateUnitOfWork())
                    {
                        var p = new DynamicParameters();
                        p.Add("@CampaignID", sqtAffID);
                        _DboCampaign=
                           context.Query<DboCampaign>("dbo.GetAccountID", p, commandType: CommandType.StoredProcedure).FirstOrDefault();
                    }

                }

                using (var context = CreateContext())
                {
                    using (var scope = context.CreateUnitOfWork())
                    {
                        var p = new DynamicParameters();
                        p.Add("@RegistrationCode", _RegistrationRegistration.RegistrationCode);
                        p.Add("@Email", _RegistrationRegistration.Email);
                        p.Add("@Confirmed", _RegistrationRegistration.Confirmed);
                        p.Add("@ConfirmedOn", _RegistrationRegistration.ConfirmedOn);
                        p.Add("@ConfirmedIPAddress", _RegistrationRegistration.ConfirmedIPAddress);
                        p.Add("@Password", _RegistrationRegistration.Password);
                        p.Add("@CampaignId", _DboCampaign.CampaignID);
                        p.Add("@PartnerAccountID", _DboCampaign.AccountID);
                        p.Add("@timezonebyIP", _RegistrationRegistration.timezonebyIP);
                        p.Add("@AccountID", null, dbType: DbType.Int64, direction: ParameterDirection.Output);
                        
                        context.Execute("[Registration].[RegistrationConfirmRegistration]", p, commandType: CommandType.StoredProcedure);
                        scope.SaveChanges();
                        _accountid=p.Get<Int64>("@AccountID");
                    }
                }
               

                using (var context = CreatePartnerContext())
                {
                    using (var scope = context.CreateUnitOfWork())
                    {
                        var p = new DynamicParameters();
                        p.Add("@AffiliateID", _DboCampaign.AccountID);
                        p.Add("@CampaignID", _DboCampaign.CampaignID);
                        p.Add("@SquareTakeoffAccountID", _accountid);
                        p.Add("@licensecount", 0);
                        p.Add("@perlicensecost", 0);
                        p.Add("@Action", "Registered");
                        int i = context.Execute("dbo.INSERTTRANDETAILFROMPRODDB", p, 30, commandType: CommandType.StoredProcedure);
                        scope.SaveChanges();
                        if (i > 0)
                            return _accountid;


                    }
                }

                return _accountid;

            }
            catch (Exception ex)
            {
                SquareTakeoff.Logging.ILogService logService = new SquareTakeoff.Logging.FileLogService(typeof(RegistrationRegistration));
                logService.Error(ex.Message);
                logService.Error(ex.StackTrace);
                if (ex.InnerException != null)
                {
                    logService.Error(ex.InnerException.Message);
                }
                return _accountid;
            }

public void Dispose()
        {
            //Use an upgradeable lock, because when we dispose a unit of work,
            //one of the removal methods will be called (which enters a write lock)
            _rwLock.EnterUpgradeableReadLock();
            try
            {
                while (_workItems.Any())
                {
                    var workItem = _workItems.First;
                    workItem.Value.Dispose(); //rollback, will remove the item from the LinkedList because it calls either RemoveTransaction or RemoveTransactionAndCloseConnection
                }
            }
            finally
            {
                _rwLock.ExitUpgradeableReadLock();
            }

            if (_connection != null)
            {
                _connection.Dispose();
                _connection = null;
            }
        }

Security Risk: When initializing the database connection, the connection string is logged which will display database user name and password in the log file

There is a big security risk when initializing. The constructor allows for the database connect string to connect to the database. When the connection to SQL is successful it logs the connection string which can contain the database user name and password. If the password exists in the connection string is should not be added to the logging or at least don't display that actual password in the log.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.