Exemplo n.º 1
0
        bool TryAddFacebookEventLink(string uriText, bool isBatch = false)
        {
            if (uriText.StartsWith("https://www.facebook.com/events/", StringComparison.OrdinalIgnoreCase))
            {
                string idString = uriText.Substring("https://www.facebook.com/events/".Length);
                string id       = new string(idString.TakeWhile(char.IsDigit).ToArray());
                if (id.Length > 0)
                {
                    var       fbEvent = _retriever.GetEvent(id);
                    CityEvent ev      = _importer.Import(fbEvent);
                    if (!isBatch && _events.Any(x => x.Uri == ev.Uri))
                    {
                        Console.Beep();
                        Console.Beep();
                        return(true);
                    }
                    FixDescription(ev);
                    _events.Add(ev);
                    try
                    {
                        dynamic r = _fb.Post(id + "/maybe", new { });
                        if (r.success != true)
                        {
                            throw new Exception(r.ToString());
                        }
                    }
                    catch (Exception e)
                    {
                        MessageBox.Show("Can't set rsvp: " + e, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }

                    if (!isBatch)
                    {
                        Save();
                        Console.Beep();
                    }
                    return(true);
                }
            }
            return(false);
        }
Exemplo n.º 2
0
 static void FixDescription(CityEvent ev)
 {
     ev.Description = ev.Description.Replace("\r", "").Replace(@"\", @"\\").Replace("\n", @"\n");
 }