Esempio n. 1
0
        public HttpResponseMessage GetAtp([FromUri] string squareString)
        {
            var    response = new HttpResponseMessage();
            string res      = "";

            try
            {
                InvestigationObject obj = new InvestigationObject(squareString);
                Random r             = new Random();
                string inputFileName = FILES_PATH + r.Next().ToString() + "_in.txt";
                File.WriteAllText(inputFileName, obj.AsString("cleanSquare"));

                string outputFileName = FILES_PATH + r.Next().ToString() + "_out.txt";
                res = Utils.CommandLine.Execute(FILES_PATH + @"atp.exe", inputFileName + " " + outputFileName);
                FileInfo file = new FileInfo(outputFileName);
                while (Utils.IsFileLocked(file))
                {
                    ;
                }
                res = File.ReadAllText(outputFileName);
                File.Delete(inputFileName);
                File.Delete(outputFileName);
            }
            catch (Exception e)
            {
                res = "error: " + e.ToString();
                File.WriteAllText(FILES_PATH + @"log.txt", res);
            }

            response.Content = new StringContent(res);
            response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
            return(response);
        }
Esempio n. 2
0
        public HttpResponseMessage GetInvestigationObjectForRectangle([FromUri] string squareString)
        {
            var    response = new HttpResponseMessage();
            string res      = "";

            try
            {
                InvestigationObject obj = new InvestigationObject(squareString);
                res = obj.AsString("all");
            }
            catch (Exception e)
            {
                res = "error: " + e.Message;
            }

            response.Content = new StringContent(res);
            response.Content.Headers.ContentType = new MediaTypeHeaderValue("text/html");
            return(response);
        }