Exemplo n.º 1
0
 /// <summary>
 /// Resets all properties, because there is no real logging out from Todoist.com
 /// </summary>
 public void LogOff()
 {
     _id              = 0;
     _email           = string.Empty;
     _fullName        = string.Empty;
     _apiToken        = string.Empty;
     _startPage       = new StartPage();
     _timeZone        = null;
     _timeZoneOffset  = new TimeZoneOffset();
     _timeFormat      = new TimeFormat();
     _dateFormat      = 0;
     _sortOrder       = SortOrder.OldestDatesFirst;
     _notifoAccount   = string.Empty;
     _mobileNumber    = string.Empty;
     _mobileHost      = string.Empty;
     _premiumUntil    = string.Empty;
     _defaultReminder = new DefaultReminder();
     _jsonData        = string.Empty;
 }
Exemplo n.º 2
0
        /// <summary>
        /// The analyse json.
        /// </summary>
        private void AnalyseJson()
        {
            JObject o = JObject.Parse(JsonData);

            _notifoAccount = (string)o.SelectToken("notifo");
            _apiToken      = (string)o.SelectToken("api_token");
            switch ((int)o.SelectToken("time_format"))
            {
            case 0:
                _timeFormat = TimeFormat.TwentyFourHourClock;
                break;

            case 1:
                _timeFormat = TimeFormat.TwelveHourClock;
                break;
            }

            switch ((int)o.SelectToken("sort_order"))
            {
            case 0:
                _sortOrder = SortOrder.OldestDatesFirst;
                break;

            case 1:
                _sortOrder = SortOrder.NewestDatesFirst;
                break;
            }

            _fullName     = (string)o.SelectToken("full_name");
            _mobileNumber = (string)o.SelectToken("mobile_number");
            _mobileHost   = (string)o.SelectToken("mobile_host");
            _timeZone     = (string)o.SelectToken("timezone");

            _id = (int)o.SelectToken("id");

            switch ((int)o.SelectToken("date_format"))
            {
            case 0:
                _dateFormat = DateFormat.DdMmYyyy;
                break;

            case 1:
                _dateFormat = DateFormat.MmDdYyyy;
                break;
            }

            _premiumUntil = (string)o.SelectToken("premium_until");

            JToken timeZoneString = o.SelectToken("tz_offset");

            _timeZoneOffset = new TimeZoneOffset(
                timeZoneString.First.Value <string>(),
                timeZoneString.First.Next.Value <int>(),
                timeZoneString.First.Next.Next.Value <int>(),
                timeZoneString.First.Next.Next.Next.Value <bool>());

            switch ((string)o.SelectToken("default_reminder"))
            {
            case "email":
                _defaultReminder = DefaultReminder.Email;
                break;

            case "mobile":
                _defaultReminder = DefaultReminder.Mobile;
                break;

            case "notifo":
                _defaultReminder = DefaultReminder.Notifo;
                break;

            case "no_defalt":
                _defaultReminder = DefaultReminder.NoDefault;
                break;
            }

            _email = (string)o.SelectToken("email");
        }