示例#1
0
        public void SolutionRequestToXmlTest()
        {
            //Arrange
            SolutionRequest sr = new SolutionRequest(123);

            //Act
            byte[] data = sr.GetXmlData();

            //Assert
            Assert.IsNotNull(data);

            Debug.WriteLine(System.Text.Encoding.UTF8.GetString(data));
        }
示例#2
0
        public void SolutionRequestParseTest()
        {
            //Arrange
            SolutionRequest sr = new SolutionRequest(123);
            byte[] data = sr.GetXmlData();

            //Act
            XMLParser parser = new XMLParser(data);

            //Assert
            Assert.IsNotNull(parser);
            Assert.AreEqual(MessageTypes.SolutionRequest, parser.MessageType);
            Assert.AreEqual(sr.Id, ((SolutionRequest)parser.Message).Id);
        }
示例#3
0
        public void SolutionRequestConstructorTest()
        {
            //Arrange
            SolutionRequest solutionRequest;

            //Act
            solutionRequest = new SolutionRequest(0);

            //Assert
            Assert.IsNotNull(solutionRequest);
        }
示例#4
0
        /// <summary>
        /// Pobiera status przetwarzania problemu i wyswietla na konsole
        /// </summary>
        public void getProblemStatus()
        {
            SolutionRequest solution_request = new SolutionRequest(problem_id);

            byte[] solution_response = client.Work(solution_request.GetXmlData());
            if (solution_response != null)
            {
                XMLParser parser = new XMLParser(solution_response);
                if (parser.MessageType == MessageTypes.Solutions)
                {
                    Solutions solutions_status = parser.Message as Solutions;
                    if (solutions_status != null)
                    {
                        Console.WriteLine("Odebrano ID: {0}, problem {1}", solutions_status.Id, solutions_status.ProblemType);

                        string computing_status = null;
                        if (solutions_status.SolutionsList != null && solutions_status.SolutionsList.Count() == 0)
                            Console.WriteLine("Solution status received: no solutions available on the list");
                        else
                        foreach (Solution s in solutions_status.SolutionsList)
                        {
                            switch (s.Type)
                            {
                                case SolutionType.Final:
                                    computing_status = "Final";

                                    SolutionContainer a = (SolutionContainer)new BinaryFormatter().Deserialize(new MemoryStream(s.Data));

                                    Console.WriteLine();
                                    Console.WriteLine("MinCost = " + a.MinCost);
                                    Console.WriteLine();
                                    foreach (var q in a.MinPath)
                                    {
                                        foreach (var w in q)
                                            Console.Write(w + ", ");
                                        Console.WriteLine();
                                    }
                                    Console.WriteLine();
                                    foreach (var q in a.Times)
                                    {
                                        foreach (var w in q)
                                            Console.Write(w + ", ");
                                        Console.WriteLine();
                                    }

                                    TimeSpan ts = new TimeSpan((long)s.ComputationsTime*10000000);
                                     Console.WriteLine("Time: " + ts.ToString());

                                    break;
                                case SolutionType.Ongoing:
                                    computing_status = "OnGoing";
                                    break;
                                case SolutionType.Partial:
                                    computing_status = "Partial";

                                    break;
                            }

                            Console.WriteLine("Task Id: {0}, computation status: {1}", s.TaskId, computing_status);
                        }

                    }
                }
            }
            else
            {
                Console.WriteLine("ComputationalClient: check solutions status failed");
            }
        }