Пример #1
0
 public override void Initialize(User todoistUser)
 {
     base.Initialize(todoistUser);
     foreach (Item item in this.Items)
     {
         item.Initialize(todoistUser);
     }
 }
Пример #2
0
        public Form1()
        {
            InitializeComponent();
            var apiUser = ConfigurationManager.AppSettings["habitUserID"];
            var apiToken = ConfigurationManager.AppSettings["habitToken"];
            var tUser = ConfigurationManager.AppSettings["todoistUser"];
            var tPass = ConfigurationManager.AppSettings["todoistPassword"];

            _hClient = new HabitRPGClient("https://habitrpg.com/api/v2/", apiUser, apiToken);
            _tClient = Todoist.Login(tUser, tPass);

            aTimer = new System.Timers.Timer(900000);

            // Hook up the Elapsed event for the timer.
            aTimer.Elapsed += TodoistToHabit;

            // Set the Interval to 2 seconds (2000 milliseconds).
            aTimer.Interval = 900000;
            aTimer.Enabled = true;
            SetText(string.Format("Next update at {0}", DateTime.Now.AddMinutes(15)));
        }
Пример #3
0
        public override void Initialize(User todoistUser)
        {
            base.Initialize(todoistUser);

            this.TodoText = this.Content;

            Regex linkRegex = new Regex(@"(http[\S]+) \((.+?)\)");
            MatchCollection linkMatches = linkRegex.Matches(this.Content);
            foreach (Match linkMatch in linkMatches)
            {
                string url = linkMatch.Groups[1].Value;
                string description = linkMatch.Groups[2].Value;

                this.TodoText = this.TodoText.Replace(url, "");
                this.TodoText = this.TodoText.Replace("(" + description + ")", description + " [LINK]");
                this.TodoText = this.TodoText.Trim();

                this.Links.Add(new ItemLink { Url = url, Description = description });
            }

            Regex gmailRegex = new Regex(@"\[\[gmail=([a-z0-9]+)@gmail, (.*)\]\](.*)");
            if (gmailRegex.IsMatch(this.Content))
            {
                //Handle gmail items, their Content looks like this:
                //[[gmail=12c68e48edeae5b1@gmail, gMailSubject]] todoText
                //gmail link looks like this:
                //https://mail.google.com/mail/#inbox/12c68e48edeae5b1

                Match match = gmailRegex.Match(this.Content);

                this.GMailLinkUrl = String.Format("https://mail.google.com/mail/#inbox/{0}", match.Groups[1].Value);
                this.GMailSubject = match.Groups[2].Value;
                this.TodoText = match.Groups[3].Value.Trim();

                this.Content = String.Format("{0} {1}", this.GMailSubject, this.TodoText);
            }
        }
Пример #4
0
 /// <summary>
 /// This method is called right after a json responce has been deserialized to a strongly typed object. Place any kind of initialization code here, such as assigning the Owner member.
 /// </summary>
 /// <param name="todoistUser">The current todoist user.</param>
 public virtual void Initialize(User todoistUser)
 {
     this.Owner = todoistUser;
 }