管道基础大数据平台系统开发-【CS】-ExportMap
13693261870
2024-09-07 8d7a67ab1d635cb954337d8a767878ae526dd3dc
ExportMap/Controllers/TBController.cs
@@ -7,6 +7,8 @@
using System.Net.Http;
using System.Web.Http;
using System.IO;
using System.Diagnostics;
using System.Threading;
namespace ExportMap.Controllers
{
@@ -36,5 +38,46 @@
                return ResponseMsg<string>.fail(ex.Message);
            }
        }
        [HttpGet] // http://localhost/ExportMap/TB/Test
        public ResponseMsg<string> Test()
        {
            try
            {
                Stopwatch sw = new Stopwatch();
                sw.Start();
                string err = null;
                bool rs = TBUtils.Test(ref err);
                sw.Stop();
                return ResponseMsg<string>.success((rs ? "成功" : "失败") + ",耗时:" + sw.ElapsedMilliseconds / 1000.0 + " s", rs.ToString());
            }
            catch (Exception ex)
            {
                LogOut.Error(ex.Message + "\r\n" + ex.StackTrace);
                return ResponseMsg<string>.fail(ex.Message);
            }
        }
        [HttpGet] // http://localhost/ExportMap/TB/Wait?seconds=10
        public ResponseMsg<string> Wait(long seconds)
        {
            try
            {
                Stopwatch sw = new Stopwatch();
                sw.Start();
                Thread.Sleep(new TimeSpan(seconds * 10 * 1000 * 1000));
                sw.Stop();
                return ResponseMsg<string>.success("成功", "耗时:" + sw.ElapsedMilliseconds / 1000.0 + " s");
            }
            catch (Exception ex)
            {
                LogOut.Error(ex.Message + "\r\n" + ex.StackTrace);
                return ResponseMsg<string>.fail(ex.Message);
            }
        }
    }
}