コード例 #1
0
ファイル: Program.cs プロジェクト: rdodesigns/esoma
        static void Main(string[] args)
        {
            string serverIp = "localhost";
            int serverPort = 10000;
            bool testMode = false;

            if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings[IP_KEY]))
                serverIp = ConfigurationManager.AppSettings[IP_KEY];

            if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings[PORT_KEY]))
                serverPort = Int32.Parse(ConfigurationManager.AppSettings[PORT_KEY]);

            if (!String.IsNullOrEmpty(ConfigurationManager.AppSettings[TESTMODE_KEY]))
                testMode = bool.Parse(ConfigurationManager.AppSettings[TESTMODE_KEY]);

            if (!testMode)
            {
                using (_client = new TCPClient(serverIp, serverPort))
                {
                    _client.UserName = CONNECT_NAME;
                    _client.DataManager += HandleClientDataManager;
                    _client.Connect();

                    while (_continue)
                    {
                        /*
                        if (_isConnected && _isReceiving && (_lastReceived - DateTime.Now).Seconds > 5)
                        {
                            _isReceiving = false;
                            _lastReceived = DateTime.MinValue;
                        }
                        */
                    }
                }
            }
            else // run testing code
            {
                DataRequestor dr = new DataRequestor();
                IndivoInitialization init = new IndivoInitialization("rpoole", "rpoole-dope75");

                string accountId = dr.Login(init.UserName, init.Password);
                ExercisePlan exPlan = dr.GetExercisePlan(accountId);
                Demographics demo = dr.GetDemographics(accountId);
                IndivoExercisePlan plan = CreateIndivoExercisePlan(accountId, exPlan, demo);
                Console.WriteLine(plan.Plan.exerciseGroups.Count);
                plan = plan.GetTodaysExercisePlan();
                Console.WriteLine(plan.Plan.exerciseGroups.Count);
            }

            return;
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: rdodesigns/esoma
        private static void InitializeIndivo(string[] dataArray)
        {
            Console.WriteLine("Initializing");

            if (dataArray.Length > 1)
            {
                string jsonString = dataArray[1];
                Console.WriteLine(jsonString);
                IndivoInitialization init = new IndivoInitialization(jsonString);

                Console.WriteLine("Getting init data from indivo using username: "******" and password: " + init.Password);

                DataRequestor dr = new DataRequestor();
                string accountId = dr.Login(init.UserName, init.Password);
                Demographics demo = dr.GetDemographics(accountId);
                ExercisePlan exPlan = dr.GetExercisePlan(accountId);
                IndivoExercisePlan plan = CreateIndivoExercisePlan(accountId, exPlan, demo);
                //plan = plan.GetTodaysExercisePlan();

                SendExercisePlan(plan);
            }
            else //no data from server
            {
                _continue = false;
            }
        }