Exemplo n.º 1
0
        private void divisionEntry()
        {
            if (isOnline)
            {
                int b = 0;
                TokenRing.waitForToken();
                getListOfEvents(false);

                Console.WriteLine("Input the number: ");
                String date = Console.ReadLine();
                b = Convert.ToInt32(date);

                String lastLine = File.ReadLines("Calendar.txt").Last();
                result = Convert.ToInt32(lastLine);
                calculation_entry entry = new calculation_entry(result, b);
                entry.writeToFile_division();

                foreach (HostIPnPort h in activeNodes)
                {
                    if (!h.Equals(thisMachineIpnPort))
                    {
                        addOverRPC(h.getFullUrl(), entry.makeString());
                    }
                }
                TokenRing.sendToken();
            }
            else
            {
                Console.WriteLine("Node is offline! Operation is not allowed");
            }
        }
Exemplo n.º 2
0
        private void subtractionEntry()
        {
            if (isOnline)
            {   int b= 0;
                TokenRing.waitForToken();
                getListOfEvents(false);

                Console.WriteLine("Input the number: ");
                String date = Console.ReadLine();
                b = Convert.ToInt32(date);

                String lastLine = File.ReadLines("Calendar.txt").Last();
                result = Convert.ToInt32(lastLine);
                calculation_entry entry = new calculation_entry(result,b);
                entry.writeToFile_subtraction();

                 foreach (HostIPnPort h in activeNodes)
                {
                    if (!h.Equals(thisMachineIpnPort))
                    {
                        addOverRPC(h.getFullUrl(), entry.makeString());
                    }
                }
                TokenRing.sendToken();
            }
            else
            {
                Console.WriteLine("Node is offline! Operation is not allowed");
            }
        }