예제 #1
0
        public static RunPackage GenerateExecRunPackage(bool readgpx)
        {
            JArray  tNode   = (JArray)JsonConvert.DeserializeObject(tNodeArray);
            RunJSON runJSON = new RunJSON(new RunJSON.Position(Convert.ToDouble(tNode[0]["latitude"]), Convert.ToDouble(tNode[0]["longitude"])));

            JArray bNode = (JArray)JsonConvert.DeserializeObject(bNodeArray);

            foreach (JObject bn in bNode)
            {
                runJSON.AddPosition(new RunJSON.Position(Convert.ToDouble(bn["position"]["latitude"]), Convert.ToDouble(bn["position"]["longitude"])));
            }

            while (runJSON.TotalDistance() < 2000)
            {
                runJSON.AddPosition(new RunJSON.Position(runJSON.PositionList.Last().Latitude + 0.0001f, 0f));
            }


            runJSON.DistributeTimeSpan(TimeSpan.FromMinutes(30), DateTime.Now);

            if (readgpx)
            {
                if (!runJSON.LoadGPX("map.gpx"))
                {
                    Console.WriteLine("map.gpx不存在/有问题!回退至自动生成路径!");
                }
            }
            string json = runJSON.ToJSON(runpgid, userid, bNodeArray, tNodeArray);
            string pkg  = Json2Package.Create(json);

            RunPackage package = new RunPackage();

            package.waittill = DateTime.Now + TimeSpan.FromMinutes(30);
            package.post     = pkg;
            package.utoken   = utoken;
            package.cookie   = cookie.GetCookies(new Uri(API_ROOT))[0].Value;
            return(package);
        }
예제 #2
0
        public static RunPackage GenerateFreeRunPackage(bool readgpx)
        {
            RunJSON runJSON = new RunJSON(Program.SHOUPosition);

            runJSON.AutoAddPosition(new RunJSON.Position(0.0001f, 0f), new Random().Next(210, 230), 5f);
            if (readgpx)
            {
                if (!runJSON.LoadGPX("map.gpx"))
                {
                    Console.WriteLine("map.gpx不存在/有问题!回退至自动生成路径!");
                }
            }

            string json = runJSON.ToJSON(runpgid, userid);
            string pkg  = Json2Package.Create(json);

            RunPackage package = new RunPackage();

            package.waittill = DateTime.Now + TimeSpan.FromMinutes(40);
            package.post     = pkg;
            package.utoken   = utoken;
            package.cookie   = cookie.GetCookies(new Uri(API_ROOT))[0].Value;
            return(package);
        }
예제 #3
0
        public static ReturnMessage AskExecRun()
        {
            ReturnMessage rm = new ReturnMessage(Request <JObject>(API_ROOT + API_RUN, Json2Package.Create(ExecRunJSON())));

            if (rm.Code == 200)
            {
                runpgid    = rm.Data["runPageId"].ToString();
                bNodeArray = rm.Data["ibeacon"].ToString();
                tNodeArray = rm.Data["gpsinfo"].ToString();
            }
            return(rm);
        }
예제 #4
0
        public static ReturnMessage Login(string mobile, string pass)
        {
            ReturnMessage rm = new ReturnMessage(Request <JObject>(API_ROOT + API_LOGIN, Json2Package.Create(LoginJSON(mobile, pass))));

            if (rm.Code == 200)
            {
                userid = rm.Data["userid"].ToString();
                utoken = rm.Data["utoken"].ToString();
            }
            return(rm);
        }
예제 #5
0
        public static ReturnMessage AskFreeRun()
        {
            ReturnMessage rm = new ReturnMessage(Request <JObject>(API_ROOT + API_RUN, Json2Package.Create(FreeRunJSON())));

            if (rm.Code == 200)
            {
                runpgid = rm.Data["runPageId"].ToString();
            }
            return(rm);
        }