예제 #1
0
 private static void ReadAuctionCodes(List <AuctionCodes> auctionCodes)
 {
     string[] auctionCodesLines = System.IO.File.ReadAllLines(@"AuctionCodes.txt");
     foreach (var auctionCodesLine in auctionCodesLines)
     {
         var auctionCode = new AuctionCodes();
         auctionCode.AuctionCode = auctionCodesLine;
         auctionCodes.Add(auctionCode);
     }
 }
예제 #2
0
        private static void Generate(List <AuctionCodes> auctionCodes)
        {
            var checkCode = true;

            while (checkCode)
            {
                var randomCode = RandomString(8);
                if (auctionCodes.Where(x => x.AuctionCode == randomCode).Count() == 0)
                {
                    var auctionCode = new AuctionCodes();
                    auctionCode.AuctionCode = randomCode;
                    auctionCodes.Add(auctionCode);

                    using (StreamWriter sw = File.AppendText(@"AuctionCodes.txt"))
                    {
                        sw.WriteLine('\n' + randomCode);
                    }

                    Console.WriteLine("Sugeneruotas akcijos kodas: " + randomCode);
                    checkCode = false;
                }
            }
        }