Пример #1
0
        protected override void FillRequiredFields(IsoCurrency entity)
        {
            base.FillRequiredFields(entity);
            dynamic obj = entity.AsDynamic();

            obj.CURRENCYCODE    = TestString.Substring(0, 3);
            obj.CURRENCYNUMERIC = TestString.Substring(0, 3);
        }
Пример #2
0
        protected override void FillRequiredFields(IsoCountry entity)
        {
            base.FillRequiredFields(entity);
            dynamic obj = entity.AsDynamic();

            obj.CountryAlpha2  = TestString.Substring(0, 2);
            obj.CountryNumeric = TestString;
        }
        protected override void FillRequiredFields(BillUserParamsTypeApply entity)
        {
            base.FillRequiredFields(entity);
            dynamic obj = entity.AsDynamic();

            obj.USERPARAMSTYPECODE_R    = BillUserParamsTypeTest.ExistsItem1Code;
            obj.USERPARAMSTYPEAPPLYCODE = TestString.Substring(0, 30);
            obj.USERPARAMSTYPEAPPLYNAME = TestString;
        }
Пример #4
0
        protected override void FillRequiredFields(IsoCountry obj)
        {
            base.FillRequiredFields(obj);

            obj.AsDynamic().COUNTRYCODE    = TestString;
            obj.AsDynamic().COUNTRYNAMERUS = TestString;
            obj.AsDynamic().COUNTRYALPHA2  = TestString.Substring(0, 2);
            obj.AsDynamic().COUNTRYNUMERIC = TestString;
        }
Пример #5
0
        protected override void FillRequiredFields(IsoCurrency obj)
        {
            base.FillRequiredFields(obj);

            obj.AsDynamic().CURRENCYCODE    = TestString;
            obj.AsDynamic().CURRENCYNAMERUS = TestString;
            //obj.AsDynamic().CURRENCYNUMERIC = TestString;
            obj.AsDynamic().CURRENCYNUMERIC = String.Format("IC{0}", TestString.Substring(Math.Max(0, TestString.Length - 1)));
        }
Пример #6
0
        protected override void FillRequiredFields(Factory entity)
        {
            base.FillRequiredFields(entity);
            dynamic obj = entity.AsDynamic();

            obj.FACTORYCODE = TestString.Substring(0, 3);
            obj.FACTORYNAME = TestString;
            obj.PARTNERID_R = TstMandantId;
        }
Пример #7
0
        public string Result()
        {
            int Sum  = 0;
            int Sum2 = 0;
            int MaxX = Instructions.Length;
            int MaxY = Instructions[0].Length;
            Dictionary <char, Coordinate> PlacesToBe = new Dictionary <char, Coordinate>();
            Dictionary <char, Coordinate> TwoPlaces  = new Dictionary <char, Coordinate>();
            StringPermutator Purme = new StringPermutator();

            bool[,] TheGrid = new bool[MaxX, MaxY];
            Dictionary <string, int> Distances = new Dictionary <string, int>();

            //Make the grid and collect the targets
            for (int x = 0; x < MaxX; x++)
            {
                for (int y = 0; y < MaxY; y++)
                {
                    if (Instructions[x][y] == '#')
                    {
                        TheGrid[x, y] = true;
                    }
                    else
                    {
                        TheGrid[x, y] = false;
                        if (char.IsDigit(Instructions[x][y]))
                        {
                            PlacesToBe.Add(Instructions[x][y], new Coordinate(x, y));
                        }
                    }
                }
            }
            //Pick out all the pair distances
            foreach (KeyValuePair <char, Coordinate> kx in PlacesToBe)
            {
                foreach (KeyValuePair <char, Coordinate> ky in PlacesToBe)
                {
                    if (kx.Key != ky.Key)
                    {
                        TwoPlaces.Add(kx.Key, kx.Value);
                        TwoPlaces.Add(ky.Key, ky.Value);
                        KeyValuePair <string, int> WhyCantIUseThisDirectly = GetDistance(TwoPlaces, TheGrid);
                        if (!Distances.ContainsKey(WhyCantIUseThisDirectly.Key))
                        {
                            Distances.Add(WhyCantIUseThisDirectly.Key, WhyCantIUseThisDirectly.Value);
                        }
                        TwoPlaces.Clear();
                    }
                }
            }
            //make a list of possible sequenses
            List <char>   PossibleSequence = new List <char>();
            List <string> AllThePossibleSequences;
            string        TheFirstSequence = "";

            foreach (KeyValuePair <char, Coordinate> k in PlacesToBe)
            {
                PossibleSequence.Add(k.Key);
                TheFirstSequence += k.Key;
            }
            TheFirstSequence        = TheFirstSequence.Remove(0, 1);
            AllThePossibleSequences = Purme.GetStrings(TheFirstSequence);
            int    TestLenght;
            string TestString;

            //make a big sum
            foreach (KeyValuePair <string, int> k in Distances)
            {
                Sum += k.Value;
            }
            Sum2 += Sum;
            //Go through all the strings
            foreach (string s in AllThePossibleSequences)
            {
                TestLenght = 0;
                TestString = s.Insert(0, "0");
                string      TesterString;
                List <char> ToSort = new List <char>();
                for (int i = 0; i < s.Length; i++)
                {
                    TesterString = TestString.Substring(i, 2);
                    foreach (char c in TesterString)
                    {
                        ToSort.Add(c);
                    }
                    ToSort.Sort();
                    TesterString = "";
                    foreach (char c in ToSort)
                    {
                        TesterString += c;
                    }
                    ToSort.Clear();
                    TestLenght += Distances[TesterString];
                }
                if (TestLenght < Sum)
                {
                    Sum = TestLenght;
                }
            }
            // del 2
            foreach (string s in AllThePossibleSequences)
            {
                TestLenght  = 0;
                TestString  = s.Insert(0, "0");
                TestString += "0";
                string      TesterString;
                List <char> ToSort = new List <char>();
                for (int i = 0; i <= s.Length; i++)
                {
                    TesterString = TestString.Substring(i, 2);
                    foreach (char c in TesterString)
                    {
                        ToSort.Add(c);
                    }
                    ToSort.Sort();
                    TesterString = "";
                    foreach (char c in ToSort)
                    {
                        TesterString += c;
                    }
                    ToSort.Clear();
                    TestLenght += Distances[TesterString];
                }
                if (TestLenght < Sum2)
                {
                    Sum2 = TestLenght;
                }
            }
            stopWatch.Stop();
            TimeSpan ts = stopWatch.Elapsed;

            return("Del 1: " + Sum + " och del 2: " + Sum2 + " Executed in " + ts.TotalMilliseconds.ToString() + " ms");
        }