private static void FixedWidthSortMurgePurge <T>(string dbConnPath, string line,
                                                         MasterFixedWidthFileSource <T> master,
                                                         DelimitedFileSource <T> detail,
                                                         MergePurgeParam mgPurgeParam,
                                                         Action <MergePurgeParam> processData,
                                                         MergePurgeResults mgPurgeResults,
                                                         DataMode processMode,
                                                         StreamWriter[] actionWriters)
        {
            SortKey <T> srtKey = null;

            using (SqliteRepository <T> sqlRepo = new SqliteRepository <T>(dbConnPath))
            {
                srtKey = sqlRepo.KeyInDb(detail.GetKey(mgPurgeParam.DetailFields, line));
            }
            mgPurgeParam.KeyFound = srtKey.Found;
            string masterData = !srtKey.Found ? string.Empty : srtKey.Data;

            if (mgPurgeParam.KeyFound)
            {
                mgPurgeParam.MasterFields = GetMasterFields <T>(master, masterData);
            }
            if (processData != null)
            {
                processData(mgPurgeParam);
                mgPurgeResults.IncrementAction(mpAction: mgPurgeParam.DataAction);
                string detailLine    = GetDetailLine <T>(detail, mgPurgeParam);
                string newMasterData = GetNewMasterDataFixedWidth(GetMasterLine <T>(master, mgPurgeParam));
                PerformDataActionForPassiveModeWriter(mgPurgeParam.DataAction, mgPurgeParam.KeyFound, processMode, detailLine, actionWriters);
                PerformDataAction(mgPurgeParam, dbConnPath, processMode, newMasterData, srtKey);
            }
        }
        private static void PerformDataAction <T>(MergePurgeParam mgPurgeParam,
                                                  string dbConnPath,
                                                  DataMode processMode,
                                                  string newMasterData,
                                                  SortKey <T> sortKey
                                                  )
        {
            using (SqliteRepository <T> sqlRepo = new SqliteRepository <T>(dbConnPath))
            {
                switch (mgPurgeParam.DataAction)
                {
                case MergePurgeAction.Add:
                    if (!mgPurgeParam.KeyFound)
                    {
                        if (processMode == DataMode.Active)
                        {
                            sqlRepo.Add(sortKey.Key, newMasterData);
                        }
                    }
                    break;

                case MergePurgeAction.Delete:
                    if (mgPurgeParam.KeyFound)
                    {
                        if (processMode == DataMode.Active)
                        {
                            sqlRepo.Delete(sortKey.Id);
                        }
                    }
                    break;

                case MergePurgeAction.Update:
                    if (mgPurgeParam.KeyFound)
                    {
                        if (processMode == DataMode.Active)
                        {
                            sqlRepo.Update(sortKey.Id, newMasterData);
                        }
                    }

                    break;

                default:
                    break;
                }
            }
        }