Exemplo n.º 1
0
        /// <summary>
        /// Add Logger service to services pool
        /// </summary>
        /// <param name="services"></param>
        /// <param name="connectionString"></param>
        /// <remarks>
        /// This logger will save logs into database
        /// </remarks>
        public static void AddDBLogger(this IServiceCollection services, string connectionString)
        {
            //Create a storedProcedure instance for saving log on database
            var storedProcedure = new DP.DapperORM.StoredProcedure.SP_Log_Insert(connectionString);

            //Pass the storedProcedure to the dbLogger constructor
            var dbLogger = new Logic.Log.DB(storedProcedure);

            //Add dbLogger as a service to the service pool
            services.AddSingleton <Logic.Log.ILog>(dbLogger);
        }
Exemplo n.º 2
0
        public DBResult SP_Log_Insert(Models.Database.StoredProcedures.SP_Log_Insert.Inputs inputs,
                                      ISP <Models.Database.StoredProcedures.SP_Log_Insert.Inputs> sp = null)
        {
            if (inputs == null)
            {
                throw new ArgumentNullException("Invalid inputs data.");
            }

            if (string.IsNullOrEmpty(inputs.MSG))
            {
                throw new ArgumentNullException("Text message could not be empty.");
            }

            if (sp == null)
            {
                sp = new DP.DapperORM.StoredProcedure.SP_Log_Insert(GetConnectionString());
            }

            var rst = sp.Call(inputs);

            return(rst);
        }