Example #1
0
        private void MapDatasetRules()//this method is terrible. Doesn't matter, all of this is getting replaced, anyway.
        {
            // Console.Clear();

            var inputSets     = _jobState.GetinputSets();
            var outputColumns = _jobState.GetOutputColumns();
            var outputsetName = _jobState.GetOutputsetName();

            for (int i = 0; i < inputSets.Count; i++)//loop through inputsets
            {
                var inputset = inputSets.ElementAt(i);

                for (int j = 0; j < inputset.Columns.Length; j++)  //loop through inputset columns
                {
                    for (int k = 0; k < outputColumns.Length; k++) //loop through output columns
                    {
                        var YNSB = "";

                        do
                        {
                            if (_ruleChecker.DoesRuleExist(inputset, k))//if a rule for the output (k) index exists, skip.
                            {
                                break;
                            }

                            _log.LogInformation("Map [{DatasetName}] column \"{inputsetColumns}\" to --> [{outputsetName}] column \"{outputColumns}\"\n", inputset.DatasetName, inputset.Columns[j], outputsetName, outputColumns[k]);

                            _log.LogInformation("Yes, No, skip, or back [Y,N,S,B]");

                            YNSB = Console.ReadLine().ToUpper();

                            if (YNSB.Equals("Y"))//if yes, make the maprule
                            {
                                var rule = new MapRule
                                {
                                    OriginIndex = j,
                                    TargetIndex = k
                                };

                                inputset.MapRules.Add(rule);

                                j++;
                            }

                            else if (YNSB.Equals("N"))//break do while loop, K gets incrimented
                            {
                                break;
                            }
                            else if (YNSB.Equals("S"))//Incriment J, unless J is at the last index, in whicn case, break the loop.
                            {
                                if (j == inputset.Columns.Length - 1)
                                {
                                    break;
                                }
                                else
                                {
                                    j++;
                                }
                            }
                            else if (YNSB.Equals("B"))//this doesn't work properly yet
                            {
                                if (k > 0)
                                {
                                    k--;//Need to remove a rule is the previous input generated one. Come back to this. Maybe use a queue and then convert to list once all rules are created.
                                }
                                else
                                {
                                    _log.LogInformation("Can not go back any further.");
                                }
                            }
                            else
                            {
                                _log.LogInformation("Invalid input.");
                            }
                        } while (true);

                        if (YNSB.Equals("y"))
                        {
                            break;
                        }
                    }
                }
            }
        }