Exemplo n.º 1
0
        private static void FileReadingChoice()
        {
            string path;
            int    line;

            Console.WriteLine();
            Console.WriteLine();

            Console.WriteLine("Podaj ścieżkę dostępu do pliku:");
            path = Console.ReadLine();

            bool lineParsed = false;

            do
            {
                Console.WriteLine("Określ nr linii w pliku do odczytania:");
                lineParsed = int.TryParse(Console.ReadLine(), out line);
            }while (!lineParsed);

            FileReading reading  = new FileReading(path, line, true);
            String      fileread = reading.LineReading();

            Console.WriteLine(fileread);

            Console.ReadKey();
        }
        public IActionResult ChooseFile()
        {
            FileReading fileReading = new FileReading();
            var         files       = fileReading.AllFiles();

            ViewBag.Files = files;

            return(View());
        }
Exemplo n.º 3
0
        public async Task LoadStuff()
        {
            UI.InitialiseOptionLoaderDict();
            AvailablePerks = AvailablePerks ?? FileReading.LoadJSON <AvailablePerks>("Data/Perks/Perks.txt");
            LoadLottery();
            LoadActivity();
            CheckEvents();

            await AMI.Neitsillia.Areas.Nests.Nest.LoadNests();

            AMI.Handlers.TaskHandler.Initiate();
            AMI.Neitsillia.NPCSystems.PopulationHandler.Start();
        }
Exemplo n.º 4
0
        internal static Campaign Load(string name)
        {
            if (File.Exists(name))
            {
                return(FileReading.LoadJSON <Campaign>(name));
            }

            foreach (FileInfo file in new DirectoryInfo(
                         cmpgPath).GetFiles())
            {
                if (file.Name == name)
                {
                    return(FileReading.LoadJSON <Campaign>(file.FullName));
                }
            }
            return(null);
        }
Exemplo n.º 5
0
        //Lottery
        void LoadLottery()
        {
            if (lottery != null)
            {
                return;
            }

            if (File.Exists(Lottery.savePath))
            {
                lottery = FileReading.LoadJSON <Lottery>(Lottery.savePath);
            }
            else
            {
                lottery = new Lottery(1, 1.00);
            }

            Task lotteryDueTime = new Task(async() => await LotteryThread());

            lotteryDueTime.Start();
        }
Exemplo n.º 6
0
 public static void Main()
 {
     FileReading file = new FileReading();
     file.ReadFile();
 }
Exemplo n.º 7
0
 internal void Save()
 => FileReading.SaveJSON(this, savePath);
Exemplo n.º 8
0
 public static GuildSettings LoadJSONGuild(string guildID)
 {
     return(FileReading.LoadJSON <GuildSettings>(savePath + guildID));
 }
        public IActionResult File(string fileName)
        {
            FileReading         fileReading      = new FileReading();
            FrankWolf           frank            = new FrankWolf();
            Product             product          = new Product();
            List <OrderProduct> changedFrank     = new List <OrderProduct>();
            List <OrderProduct> changedAnnealing = new List <OrderProduct>();
            List <OrderProduct> changedGenetic   = new List <OrderProduct>();

            Order order = fileReading.FileRead(fileName);
            int   count = order.OrdersProducts.Count;

            order.AllSum = 0;

            if (order.OrdersProducts.Count() != 0)
            {
                foreach (var orderProduct in order.OrdersProducts)
                {
                    order.AllWriteOffSum = order.AllWriteOffSum + orderProduct.WriteOffSum;
                    orderProduct.Price   = Convert.ToInt32((double)orderProduct.WriteOffSum / orderProduct.Amount);
                    orderProduct.Sum     = Convert.ToInt32((double)orderProduct.Price * orderProduct.Amount);
                    order.AllSum         = order.AllSum + (orderProduct.Amount * orderProduct.Price);
                    order.Disbalance     = Math.Abs(order.AllWriteOffSum - order.AllSum);
                }

                ViewBag.Order = order;
                var xNew = frank.FrankWolfMethod(order, order.OrdersProducts).ToList();

                changedFrank = BetterPrices(changedFrank, order.OrdersProducts.ToList(), xNew);
                int[] q = new int[count];
                int[] s = new int[count];
                int   i = 0;
                foreach (var op in order.OrdersProducts)
                {
                    s[i] = op.WriteOffSum;
                    q[i] = op.Amount;
                    i++;
                }
                Methods.Task       task = new Methods.Task(q, s, order.AllWriteOffSum);
                SimulatedAnnealing simulatedAnnealing = new SimulatedAnnealing(task, 200, 100);
                TaskPair           pair = simulatedAnnealing.executeAlgorithm();
                changedAnnealing = BetterPrices(changedAnnealing, order.OrdersProducts.ToList(), pair.X.ToList());

                Genetic  genetic     = new Genetic(task);
                TaskPair pairGenetic = genetic.ExecuteAlgorithm();
                changedGenetic = BetterPrices(changedGenetic, order.OrdersProducts.ToList(), pairGenetic.X.ToList());

                ViewBag.ProductsFrank     = changedFrank;
                ViewBag.ProductsAnnealing = changedAnnealing;
                ViewBag.ProductsGenetic   = changedGenetic;

                var sumFrank = 0; var writeOffFrank = 0;
                foreach (var op in changedFrank)
                {
                    sumFrank      += op.Sum;
                    writeOffFrank += op.WriteOffSum;
                }
                ViewBag.SumFrank        = sumFrank;
                ViewBag.AllSumFrank     = writeOffFrank;
                ViewBag.DisbalanceFrank = Math.Abs(sumFrank - writeOffFrank);
                var sumAnnealing = 0; var writeOffAnnealing = 0;
                foreach (var op in changedAnnealing)
                {
                    sumAnnealing      += op.Sum;
                    writeOffAnnealing += op.WriteOffSum;
                }
                ViewBag.SumAnnealing        = sumAnnealing;
                ViewBag.AllSumAnnealing     = writeOffAnnealing;
                ViewBag.DisbalanceAnnealing = Math.Abs(sumAnnealing - writeOffAnnealing);

                var sumGenetic = 0; var writeOffGenetic = 0;
                foreach (var op in changedGenetic)
                {
                    sumGenetic      += op.Sum;
                    writeOffGenetic += op.WriteOffSum;
                }
                ViewBag.SumGenetic        = sumGenetic;
                ViewBag.AllSumGenetic     = writeOffGenetic;
                ViewBag.DisbalanceGenetic = Math.Abs(sumGenetic - writeOffGenetic);
            }
            _context.SaveChanges();
            return(View(order.OrdersProducts));
        }