<commit_before>﻿using System;
using GenericServices.ActionComms;
using GenericServices.Logger;
using GenericServices.Services;

namespace GenericServices.Actions
{
    public abstract class ActionBase
    {

        private readonly IGenericLogger _logger;

        /// <summary>
        /// If true then the caller should call EF SubmitChanges if the method exited with status IsValid and
        /// it looks to see if the data part has a ICheckIfWarnings and if the WriteEvenIfWarning is false
        /// and there are warnings then it does not call SubmitChanges
        /// </summary>
        public abstract bool SubmitChangesOnSuccess { get; }
      
        /// <summary>
        /// This controls the lower value sent back to reportProgress
        /// Lower and Upper bound are there to allow outer tasks to call inner tasks 
        /// to do part of the work and still report progress properly
        /// </summary>
        public int LowerBound { get; set; }

        /// <summary>
        /// This controls the upper bound of the value sent back to reportProgress
        /// </summary>
        public int UpperBound { get; set; }

        protected ActionBase()
        {
            LowerBound = 0;
            UpperBound = 100;
            _logger = GenericLoggerFactory.GetLogger(GetType().Name);       //give it the name of the inherited type
        }

        
        //---------------------------------------------------
        //private helpers

        protected void SendtoLogger(ProgressMessage message)
        {

            switch (message.MessageType)<commit_msg>Changed ActionBase SubmitChangesOnSuccess so that inheriting classes can ignore it if they don't write to database<commit_after>﻿using System;
using GenericServices.ActionComms;
using GenericServices.Logger;

namespace GenericServices.Actions
{
    public abstract class ActionBase
    {

        private readonly IGenericLogger _logger;

        /// <summary>
        /// Override this to return true if you want the calling service to write to database.
        /// If the method exited with status IsValid and the warning check (see ICheckIfWarings)
        /// passes the it will call SubmitChanges to commit any data to the database
        /// </summary>
        public virtual bool SubmitChangesOnSuccess { get { return false; } }
      
        /// <summary>
        /// This controls the lower value sent back to reportProgress
        /// Lower and Upper bound are there to allow outer tasks to call inner tasks 
        /// to do part of the work and still report progress properly
        /// </summary>
        public int LowerBound { get; set; }

        /// <summary>
        /// This controls the upper bound of the value sent back to reportProgress
        /// </summary>
        public int UpperBound { get; set; }

        protected ActionBase()
        {
            LowerBound = 0;
            UpperBound = 100;
            _logger = GenericLoggerFactory.GetLogger(GetType().Name);       //give it the name of the inherited type
        }

        
        //---------------------------------------------------
        //private helpers

        protected void SendtoLogger(ProgressMessage message)
        {

            switch (message.MessageType)
{'fraction_non_alphanumeric': 0.09853121175030599, 'fraction_numerical': 0.0024479804161566705, 'mean_word_length': 1.8550218340611353, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 15, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6798783', 'n_tokens_mistral': 753, 'n_tokens_neox': 722, 'n_words': 317}