Beispiel #1
0
 public void StartForwardingData(ReplicatorSender sender, ReplicatorReceiver.ReplicatorReceiver replicatorReceiver)
 {
     t = new Thread(() => ForwardDataToReceiver(sender, replicatorReceiver));
     t.IsBackground = true;
     t.Start();
     Thread.Sleep(15);
 }
Beispiel #2
0
        public void ForwardDataToReceiver(ReplicatorSender sender, ReplicatorReceiver.ReplicatorReceiver replicatorReceiver)
        {
            while (true)
            {
                lock (this)
                {
                    if (sender.Data.ReceiverPropertyArray.Count >= 2)
                    {
                        if (sender.Data.ReceiverPropertyArray[0] != null && sender.Data.ReceiverPropertyArray[1] != null)
                        {
                            var data = sender.Data;
                            replicatorReceiver.DataCD = ConvertToCD(data);
                            Logger.Log(LogComponent.REPLICATOR_SENDER, LogComponent.REPLICATOR_RECEIVER, DateTime.Now,
                                       sender.Data.ReceiverPropertyArray[0].Code.ToString() + "_" +
                                       sender.Data.ReceiverPropertyArray[0].ReceiverValue + " " +
                                       sender.Data.ReceiverPropertyArray[1].Code.ToString() + "_" +
                                       sender.Data.ReceiverPropertyArray[1].ReceiverValue
                                       );

                            sender.Data.ReceiverPropertyArray.Clear();
                        }
                    }
                }
            }
        }
        public void ReplicatorReceiver_EmptyConstructor_ReturnsDefaults()
        {
            var result = new ReplicatorReceiver.ReplicatorReceiver();

            var dataCD = new CollectionDescription();

            var  hcollection = dataCD.Collection;
            bool equal       = !hcollection.ReceiverPropertyArray.Except(result.DataCD.Collection.ReceiverPropertyArray).Any();


            Assert.IsTrue(result.DataCD.ID == dataCD.ID && result.DataCD.DataSet == dataCD.DataSet && equal);

            foreach (var item in result.DataDeltaCDs.Values)
            {
                Assert.AreEqual(item.Add, new List <CollectionDescription>());
                Assert.AreEqual(item.Update, new List <CollectionDescription>());
            }
        }
        public void ReplicatorReceiverTest_ConstructorWithParameters_ReturnsDefaults()
        {
            var dataCD1 = new CollectionDescription {
                ID = 0, DataSet = 0, Collection = new HistoricalCollection {
                }
            };
            Dictionary <int, Reader.Reader> readers1 = new Dictionary <int, Reader.Reader>();

            Reader.Reader rd1 = new Reader.Reader(1);
            Reader.Reader rd2 = new Reader.Reader(2);
            Reader.Reader rd3 = new Reader.Reader(3);
            Reader.Reader rd4 = new Reader.Reader(4);

            readers1.Add(1, rd1);
            readers1.Add(2, rd2);
            readers1.Add(3, rd3);
            readers1.Add(4, rd4);
            //{
            //    {
            //        1,
            //        new Reader.Reader
            //        {
            //            ID = 1,
            //            ContainsDataset1 = false,
            //            ContainsDataset2 = false,
            //            ContainsDataset3= false,
            //            ContainsDataset4 = false,
            //            ReceivedData = new DeltaCD
            //            {
            //                Add = new  List<CollectionDescription>
            //                {
            //                    new CollectionDescription
            //                    {
            //                        ID = 1,
            //                        DataSet = 1,
            //                        Collection = new HistoricalCollection
            //                        {
            //                            ReceiverPropertyArray = new List<ReceiverProperty>
            //                            {
            //                                new ReceiverProperty
            //                                {
            //                                    Code = Code.CODE_ANALOG,
            //                                    ReceiverValue = 1110
            //                                },
            //                                new ReceiverProperty
            //                                {
            //                                    Code = Code.CODE_DIGITAL,
            //                                    ReceiverValue = 1
            //                                }
            //                            }
            //                        }
            //                    }
            //                },
            //                Update = new  List<CollectionDescription>
            //                {
            //                    new CollectionDescription
            //                    {
            //                        ID = 2,
            //                        DataSet = 1,
            //                        Collection = new HistoricalCollection
            //                        {
            //                            ReceiverPropertyArray = new List<ReceiverProperty>
            //                            {
            //                                new ReceiverProperty
            //                                {
            //                                    Code = Code.CODE_ANALOG,
            //                                    ReceiverValue = 1210
            //                                },
            //                                new ReceiverProperty
            //                                {
            //                                    Code = Code.CODE_DIGITAL,
            //                                    ReceiverValue = 0
            //                                }
            //                            }
            //                        }
            //                    },
            //                    new CollectionDescription
            //                    {
            //                        ID = 3,
            //                        DataSet = 1,
            //                        Collection = new HistoricalCollection
            //                        {
            //                            ReceiverPropertyArray = new List<ReceiverProperty>
            //                            {
            //                                new ReceiverProperty
            //                                {
            //                                    Code = Code.CODE_ANALOG,
            //                                    ReceiverValue = 1310
            //                                },
            //                                new ReceiverProperty
            //                                {
            //                                    Code = Code.CODE_DIGITAL,
            //                                    ReceiverValue = 1
            //                                }
            //                            }
            //                        }
            //                    }
            //                },
            //            }
            //        }
            //    },
            //    {
            //        2,
            //        new Reader.Reader
            //        {
            //            ID = 2,
            //            ContainsDataset1 = false,
            //            ContainsDataset2 = false,
            //            ContainsDataset3= false,
            //            ContainsDataset4 = false,
            //            ReceivedData = new DeltaCD
            //            {
            //                Add = new  List<CollectionDescription>
            //                {
            //                    new CollectionDescription
            //                    {
            //                        ID = 1,
            //                        DataSet = 1,
            //                        Collection = new HistoricalCollection
            //                        {
            //                            ReceiverPropertyArray = new List<ReceiverProperty>
            //                            {
            //                                new ReceiverProperty
            //                                {
            //                                    Code = Code.CODE_ANALOG,
            //                                    ReceiverValue = 1110
            //                                },
            //                                new ReceiverProperty
            //                                {
            //                                    Code = Code.CODE_DIGITAL,
            //                                    ReceiverValue = 1
            //                                }
            //                            }
            //                        }
            //                    }
            //                },
            //                Update = new  List<CollectionDescription>
            //                {
            //                    new CollectionDescription
            //                    {
            //                        ID = 2,
            //                        DataSet = 1,
            //                        Collection = new HistoricalCollection
            //                        {
            //                            ReceiverPropertyArray = new List<ReceiverProperty>
            //                            {
            //                                new ReceiverProperty
            //                                {
            //                                    Code = Code.CODE_ANALOG,
            //                                    ReceiverValue = 1210
            //                                },
            //                                new ReceiverProperty
            //                                {
            //                                    Code = Code.CODE_DIGITAL,
            //                                    ReceiverValue = 0
            //                                }
            //                            }
            //                        }
            //                    },
            //                    new CollectionDescription
            //                    {
            //                        ID = 3,
            //                        DataSet = 1,
            //                        Collection = new HistoricalCollection
            //                        {
            //                            ReceiverPropertyArray = new List<ReceiverProperty>
            //                            {
            //                                new ReceiverProperty
            //                                {
            //                                    Code = Code.CODE_ANALOG,
            //                                    ReceiverValue = 1310
            //                                },
            //                                new ReceiverProperty
            //                                {
            //                                    Code = Code.CODE_DIGITAL,
            //                                    ReceiverValue = 1
            //                                }
            //                            }
            //                        }
            //                    }
            //                },
            //            }
            //        }
            //    },
            //    {
            //        3,
            //        new Reader.Reader
            //        {
            //            ID = 1,
            //            ContainsDataset1 = false,
            //            ContainsDataset2 = false,
            //            ContainsDataset3= false,
            //            ContainsDataset4 = false,
            //            ReceivedData = new DeltaCD
            //            {
            //                Add = new  List<CollectionDescription>
            //                {
            //                    new CollectionDescription
            //                    {
            //                        ID = 1,
            //                        DataSet = 1,
            //                        Collection = new HistoricalCollection
            //                        {
            //                            ReceiverPropertyArray = new List<ReceiverProperty>
            //                            {
            //                                new ReceiverProperty
            //                                {
            //                                    Code = Code.CODE_ANALOG,
            //                                    ReceiverValue = 1110
            //                                },
            //                                new ReceiverProperty
            //                                {
            //                                    Code = Code.CODE_DIGITAL,
            //                                    ReceiverValue = 1
            //                                }
            //                            }
            //                        }
            //                    }
            //                },
            //                Update = new  List<CollectionDescription>
            //                {
            //                    new CollectionDescription
            //                    {
            //                        ID = 2,
            //                        DataSet = 1,
            //                        Collection = new HistoricalCollection
            //                        {
            //                            ReceiverPropertyArray = new List<ReceiverProperty>
            //                            {
            //                                new ReceiverProperty
            //                                {
            //                                    Code = Code.CODE_ANALOG,
            //                                    ReceiverValue = 1210
            //                                },
            //                                new ReceiverProperty
            //                                {
            //                                    Code = Code.CODE_DIGITAL,
            //                                    ReceiverValue = 0
            //                                }
            //                            }
            //                        }
            //                    },
            //                    new CollectionDescription
            //                    {
            //                        ID = 3,
            //                        DataSet = 1,
            //                        Collection = new HistoricalCollection
            //                        {
            //                            ReceiverPropertyArray = new List<ReceiverProperty>
            //                            {
            //                                new ReceiverProperty
            //                                {
            //                                    Code = Code.CODE_ANALOG,
            //                                    ReceiverValue = 1310
            //                                },
            //                                new ReceiverProperty
            //                                {
            //                                    Code = Code.CODE_DIGITAL,
            //                                    ReceiverValue = 1
            //                                }
            //                            }
            //                        }
            //                    }
            //                },
            //            }
            //        }
            //    },
            //    {
            //        4,
            //        new Reader.Reader
            //        {
            //            ID = 1,
            //            ContainsDataset1 = false,
            //            ContainsDataset2 = false,
            //            ContainsDataset3= false,
            //            ContainsDataset4 = false,
            //            ReceivedData = new DeltaCD
            //            {
            //                Add = new  List<CollectionDescription>
            //                {
            //                    new CollectionDescription
            //                    {
            //                        ID = 1,
            //                        DataSet = 1,
            //                        Collection = new HistoricalCollection
            //                        {
            //                            ReceiverPropertyArray = new List<ReceiverProperty>
            //                            {
            //                                new ReceiverProperty
            //                                {
            //                                    Code = Code.CODE_ANALOG,
            //                                    ReceiverValue = 1110
            //                                },
            //                                new ReceiverProperty
            //                                {
            //                                    Code = Code.CODE_DIGITAL,
            //                                    ReceiverValue = 1
            //                                }
            //                            }
            //                        }
            //                    }
            //                },
            //                Update = new  List<CollectionDescription>
            //                {
            //                    new CollectionDescription
            //                    {
            //                        ID = 2,
            //                        DataSet = 1,
            //                        Collection = new HistoricalCollection
            //                        {
            //                            ReceiverPropertyArray = new List<ReceiverProperty>
            //                            {
            //                                new ReceiverProperty
            //                                {
            //                                    Code = Code.CODE_ANALOG,
            //                                    ReceiverValue = 1210
            //                                },
            //                                new ReceiverProperty
            //                                {
            //                                    Code = Code.CODE_DIGITAL,
            //                                    ReceiverValue = 0
            //                                }
            //                            }
            //                        }
            //                    },
            //                    new CollectionDescription
            //                    {
            //                        ID = 3,
            //                        DataSet = 1,
            //                        Collection = new HistoricalCollection
            //                        {
            //                            ReceiverPropertyArray = new List<ReceiverProperty>
            //                            {
            //                                new ReceiverProperty
            //                                {
            //                                    Code = Code.CODE_ANALOG,
            //                                    ReceiverValue = 1310
            //                                },
            //                                new ReceiverProperty
            //                                {
            //                                    Code = Code.CODE_DIGITAL,
            //                                    ReceiverValue = 1
            //                                }
            //                            }
            //                        }
            //                    }
            //                },
            //            }
            //        }
            //    }
            //};
            var result1 = new ReplicatorReceiver.ReplicatorReceiver(readers1);

            // Dataset 0
            List <ReceiverProperty> receiverPropertyList = new List <ReceiverProperty>(2);

            receiverPropertyList.Add(new ReceiverProperty(ECode.CODE_ANALOG, 1001));
            receiverPropertyList.Add(new ReceiverProperty(ECode.CODE_ANALOG, 1002));
            HistoricalCollection  historicalCollection = new HistoricalCollection(receiverPropertyList);
            CollectionDescription cd = new CollectionDescription(0, 0, historicalCollection);

            result1.DataCD = cd;

            // Dataset 1
            receiverPropertyList.Clear();
            receiverPropertyList.Add(new ReceiverProperty(ECode.CODE_ANALOG, 1001));
            receiverPropertyList.Add(new ReceiverProperty(ECode.CODE_DIGITAL, 1));
            historicalCollection = new HistoricalCollection(receiverPropertyList);
            cd = new CollectionDescription(1, 1, historicalCollection);

            result1.DataCD = cd;

            // Dataset 2
            receiverPropertyList.Clear();
            receiverPropertyList.Add(new ReceiverProperty(ECode.CODE_CUSTOM, 3000));
            receiverPropertyList.Add(new ReceiverProperty(ECode.CODE_LIMITSET, 4001));
            historicalCollection = new HistoricalCollection(receiverPropertyList);
            cd = new CollectionDescription(1, 1, historicalCollection);

            result1.DataCD = cd;

            // Dataset 3
            receiverPropertyList.Clear();
            receiverPropertyList.Add(new ReceiverProperty(ECode.CODE_SINGLENODE, 6000));
            receiverPropertyList.Add(new ReceiverProperty(ECode.CODE_MULTIPLENODE, 5001));
            historicalCollection = new HistoricalCollection(receiverPropertyList);
            cd = new CollectionDescription(1, 1, historicalCollection);

            result1.DataCD = cd;

            // Dataset 4
            receiverPropertyList.Clear();
            receiverPropertyList.Add(new ReceiverProperty(ECode.CODE_CONSUMER, 2001));
            receiverPropertyList.Add(new ReceiverProperty(ECode.CODE_SOURCE, 7001));
            historicalCollection = new HistoricalCollection(receiverPropertyList);
            cd = new CollectionDescription(1, 1, historicalCollection);

            result1.DataCD = cd;


            var dataCD = new CollectionDescription {
                ID = 0, DataSet = 0, Collection = new HistoricalCollection {
                }
            };
            Dictionary <int, Reader.Reader> readers = new Dictionary <int, Reader.Reader>();
            var result = new ReplicatorReceiver.ReplicatorReceiver(readers);


            var  hcollection = dataCD.Collection;
            bool equal       = !hcollection.ReceiverPropertyArray.Except(result.DataCD.Collection.ReceiverPropertyArray).Any();


            Assert.IsTrue(result.DataCD.ID == dataCD.ID && result.DataCD.DataSet == dataCD.DataSet && equal);

            foreach (var item in result.DataDeltaCDs.Values)
            {
                Assert.AreEqual(item.Add, new List <CollectionDescription>());
                Assert.AreEqual(item.Update, new List <CollectionDescription>());
            }
        }
Beispiel #5
0
        public void StartForwardingData_Test()
        {
            try
            {
                ReplicatorSender.ReplicatorSender     sender             = new ReplicatorSender.ReplicatorSender();
                ReplicatorReceiver.ReplicatorReceiver replicatorReceiver = new ReplicatorReceiver.ReplicatorReceiver();


                sender.service.StartForwardingData(sender, replicatorReceiver);
                Thread.Sleep(500);
                sender.service.StopForwardingData();

                // Data.Count = 1
                sender.Data = new HistoricalCollection(
                    new List <ReceiverProperty>
                {
                    new ReceiverProperty(ECode.CODE_ANALOG, 1001)
                }
                    );


                sender.service.StartForwardingData(sender, replicatorReceiver);
                Thread.Sleep(500);
                sender.service.StopForwardingData();

                // Data.Count = 2
                sender.Data = new HistoricalCollection(
                    new List <ReceiverProperty>
                {
                    new ReceiverProperty(ECode.CODE_ANALOG, 1001),
                    new ReceiverProperty(ECode.CODE_ANALOG, 1002)
                }
                    );

                sender.service.StartForwardingData(sender, replicatorReceiver);
                Thread.Sleep(500);
                sender.service.StopForwardingData();

                //// sender.Data.ReceiverPropertyArray[0] = null
                //sender.Data.ReceiverPropertyArray[0] = null;
                //sender.service.StartForwardingData(sender, replicatorReceiver);
                //sender.Data = new HistoricalCollection(
                //    new List<ReceiverProperty>
                //    {
                //        new ReceiverProperty(Code.CODE_ANALOG, 1001),
                //        new ReceiverProperty(Code.CODE_ANALOG, 1002)
                //    }
                //                                      );

                //Thread.Sleep(500);
                //sender.service.StopForwardingData();

                //sender.Data.ReceiverPropertyArray[1] = null;
                //sender.service.StartForwardingData(sender, replicatorReceiver);
                //sender.Data = new HistoricalCollection(
                //    new List<ReceiverProperty>
                //    {
                //        new ReceiverProperty(Code.CODE_ANALOG, 1001),
                //        new ReceiverProperty(Code.CODE_ANALOG, 1002)
                //    }
                //                                      );


                //sender.service.StartForwardingData(sender, replicatorReceiver);

                //Thread.Sleep(500);
                //sender.service.StopForwardingData();
            }
            catch (Exception)
            {
                Assert.Fail();
            }
            Assert.Pass();


            //// Data.Count = 2,  dataset 1
            //sender.Data = new HistoricalCollection(
            //    new List<ReceiverProperty>
            //    {
            //        new ReceiverProperty(Code.CODE_ANALOG, 1001),
            //        new ReceiverProperty(Code.CODE_DIGITAL, 0)
            //    }
            //                                      );

            //sender.service.ForwardDataToReceiver(sender, replicatorReceiver);

            //// Data.Count = 2, dataset 2
            //sender.Data = new HistoricalCollection(
            //    new List<ReceiverProperty>
            //    {
            //        new ReceiverProperty(Code.CODE_CUSTOM, 3300),
            //        new ReceiverProperty(Code.CODE_LIMITSET, 4400)
            //    }


            //                                      );

            //sender.service.ForwardDataToReceiver(sender, replicatorReceiver);

            //// Data.Count = 2, dataset 3
            //sender.Data = new HistoricalCollection(
            //    new List<ReceiverProperty>
            //    {
            //        new ReceiverProperty(Code.CODE_SINGLENODE, 6232),
            //        new ReceiverProperty(Code.CODE_MULTIPLENODE, 5323)
            //    }
            //                                      );

            //sender.service.ForwardDataToReceiver(sender, replicatorReceiver);

            //// Data.Count = 2, dataset 4
            //sender.Data = new HistoricalCollection(
            //    new List<ReceiverProperty>
            //    {
            //        new ReceiverProperty(Code.CODE_CONSUMER, 7999),
            //        new ReceiverProperty(Code.CODE_SOURCE, 2000)
            //    }
            //                                      );
        }
Beispiel #6
0
        static void Main(string[] args)
        {
            Console.WriteLine(DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"));
            // Writers
            Dictionary <int, Writer.Writer> writers = new Dictionary <int, Writer.Writer>();

            // Readers
            Dictionary <int, Reader.Reader> readers = new Dictionary <int, Reader.Reader>();

            Reader.Reader rd1 = new Reader.Reader(1);
            Reader.Reader rd2 = new Reader.Reader(2);
            Reader.Reader rd3 = new Reader.Reader(3);
            Reader.Reader rd4 = new Reader.Reader(4);

            readers.Add(1, rd1);
            readers.Add(2, rd2);
            readers.Add(3, rd3);
            readers.Add(4, rd4);

            // Sender
            ReplicatorSender.ReplicatorSender s = new ReplicatorSender.ReplicatorSender();

            // Receiver
            ReplicatorReceiver.ReplicatorReceiver r = new ReplicatorReceiver.ReplicatorReceiver(readers);

            s.service.StartForwardingData(s, r);


            while (true)
            {
                System.Console.WriteLine("-------------------------------");
                System.Console.WriteLine("0 - Exit");
                System.Console.WriteLine("1 - Turn off writer");
                System.Console.WriteLine("2 - Show writers");
                System.Console.WriteLine("3 - Start new writer");
                System.Console.WriteLine("4 - Start 100 writers");
                System.Console.WriteLine("5 - Read data form database: ");
                System.Console.WriteLine("-------------------------------");

                string c = System.Console.ReadLine();

                System.Console.WriteLine();

                if (c == "0")
                {
                    foreach (var item in writers.Keys)
                    {
                        writers[item].StopSendingData();
                    }
                    break;
                }
                else if (c == "1")
                {
                    System.Console.WriteLine("Writer No: ");
                    int number;
                    try
                    {
                        number = int.Parse(System.Console.ReadLine());
                        writers[number].StopSendingData();
                        writers.Remove(number);

                        System.Console.WriteLine($"Writer {number} has been turned off.\n");
                    }
                    catch (Exception)
                    {
                        System.Console.WriteLine("Writer with that ID doesn't exist!");
                    }
                }
                else if (c == "2")
                {
                    System.Console.WriteLine("Writer list:");
                    foreach (var item in writers.Values)
                    {
                        System.Console.WriteLine($"\tWriter {item.ID}");
                    }
                }
                else if (c == "3")
                {
                    writerCounter++;
                    writers.Add(writerCounter, new Writer.Writer(writerCounter));
                    writers[writerCounter].StartSendingData(s);
                }
                else if (c == "4")
                {
                    for (int i = 0; i < 100; i++)
                    {
                        writerCounter++;
                        writers.Add(writerCounter, new Writer.Writer(writerCounter));
                        writers[writerCounter].StartSendingData(s);
                    }
                }
                else if (c == "5")
                {
                    System.Console.WriteLine("Choose code: \n");
                    System.Console.WriteLine("1) CODE_ANALOG: ");
                    System.Console.WriteLine("2) CODE_DIGITAL: ");
                    System.Console.WriteLine("3) CODE_CUSTOM: ");
                    System.Console.WriteLine("4) CODE_LIMITSET: ");
                    System.Console.WriteLine("5) CODE_SINGLENODE: ");
                    System.Console.WriteLine("6) CODE_MULTIPLENODE: ");
                    System.Console.WriteLine("7) CODE_CONSUMER: ");
                    System.Console.WriteLine("8) CODE_SOURCE: ");

                    int code_option = 0;

                    try
                    {
                        code_option = int.Parse(System.Console.ReadLine());
                        if (code_option < 1 && code_option > 8)
                        {
                            System.Console.WriteLine("Wrong input!");
                            break;
                        }
                    }
                    catch (Exception)
                    {
                        System.Console.WriteLine("Wrong input!");
                        break;
                    }



                    System.Console.WriteLine("From: ");
                    string dateFrom = System.Console.ReadLine();
                    System.Console.WriteLine("To: ");
                    string dateTo = System.Console.ReadLine();

                    switch (code_option)
                    {
                    case 1:
                        System.Console.WriteLine(rd1.service.ReadDataFromDataBase(ECode.CODE_ANALOG, 1, rd1._context, dateFrom, dateTo));
                        break;

                    case 2:
                        System.Console.WriteLine(rd1.service.ReadDataFromDataBase(ECode.CODE_DIGITAL, 1, rd1._context, dateFrom, dateTo));
                        break;

                    case 3:
                        System.Console.WriteLine(rd1.service.ReadDataFromDataBase(ECode.CODE_CUSTOM, 2, rd2._context, dateFrom, dateTo));
                        break;

                    case 4:
                        System.Console.WriteLine(rd1.service.ReadDataFromDataBase(ECode.CODE_LIMITSET, 2, rd2._context, dateFrom, dateTo));
                        break;

                    case 5:
                        System.Console.WriteLine(rd1.service.ReadDataFromDataBase(ECode.CODE_SINGLENODE, 3, rd3._context, dateFrom, dateTo));
                        break;

                    case 6:
                        System.Console.WriteLine(rd1.service.ReadDataFromDataBase(ECode.CODE_MULTIPLENODE, 3, rd3._context, dateFrom, dateTo));
                        break;

                    case 7:
                        System.Console.WriteLine(rd1.service.ReadDataFromDataBase(ECode.CODE_CONSUMER, 4, rd4._context, dateFrom, dateTo));
                        break;

                    case 8:
                        System.Console.WriteLine(rd1.service.ReadDataFromDataBase(ECode.CODE_SOURCE, 4, rd4._context, dateFrom, dateTo));
                        break;

                    default:
                        System.Console.WriteLine("Wrong input");
                        break;
                    }
                }
                else
                {
                    System.Console.WriteLine("Wrong input!");
                }
            }

            System.Console.ReadLine();
        }