protected void Page_Load(object sender, EventArgs e) { get_totals(); DropNetClient _client = new DropNetClient(_settings.dropbox_api_key(), _settings.dropbox_api_secret()); permissions(); if (Session["request_token"] != null) { Event ev = _events.@select(Convert.ToInt32(Session["dropbox_event_id"] as string)); _client.UserLogin = Session["request_token"] as DropNet.Models.UserLogin; var access_token = _client.GetAccessToken(); var account_info = _client.AccountInfo(); ev.request_token = access_token.Token.ToString(); ev.access_token = access_token.Secret.ToString(); ev.dropbox_country = account_info.country; ev.dropbox_email = account_info.email; ev.dropbox_quota = account_info.quota_info.quota.ToString(); ev.dropbox_referral = account_info.referral_link; ev.dropbox_uid = account_info.uid; ev.dropbox_username = account_info.display_name; ev = _events.update(ev); username.Attributes.Add("placeholder", account_info.display_name); email.Attributes.Add("placeholder", ev.dropbox_email); quota.Attributes.Add("placeholder", ev.dropbox_quota); referral.Attributes.Add("placeholder", ev.dropbox_referral); uid.Attributes.Add("placeholder", ev.dropbox_uid.ToString()); country.Attributes.Add("placeholder", ev.dropbox_country); } else { Response.Redirect("/events"); } }
static void Main(string[] args) { facebook _facebook = new facebook(); instagram _instagram = new instagram(); twitter _twitter = new twitter(); tags _tags = new tags(); settings _settings = new settings(); stats _stats = new stats(); Int32 facebook_count = 0; Int32 instagram_count = 0; Int32 twitter_count = 0; Int32 total_count = 0; Int32 fetch_count = _settings.refresh_count(); overrideSocial.events _events = new overrideSocial.events(); Console.WriteLine("######################## BEGINNING UPDATE SEQUENCE ########################"); Console.WriteLine(""); Console.WriteLine("######################## CHECKING FOR EVENTS THAT ARE READY FOR UPDATE ########################"); Console.WriteLine(""); // loop through EVENTS that are DUE and UPDATE foreach (Event ev in _events.ready_for_pull()) { Console.WriteLine(ev.title + " with last update time of: " + ev.last_update.ToShortDateString() + " @ " + ev.last_update.ToShortTimeString()); Console.WriteLine(""); Console.WriteLine("Checking for Active Tags & Usernames to Import..."); Console.WriteLine(""); instagram_count = 0; twitter_count = 0; facebook_count = 0; total_count = 0; foreach (Tag t in _tags.select(ev.id, true)) { Console.WriteLine("Beginning Evaluation for Term: " + t.value); Console.WriteLine(""); if (t.instagram) { Console.WriteLine("###################### INSTAGRAM PULL #########################"); Console.WriteLine(""); if (t.is_tag) { Console.WriteLine("Importing Records from Instagram for Hashtag #" + t.value); instagram_count = instagram_count + _instagram.fetch2(t.value, ev.id, t.id); } else { Console.WriteLine("Importing Records from Instagram for Username @" + t.value); instagram_count = instagram_count + _instagram.fetch_by_username(t.value, ev.id, t.id); } } if (t.twitter) { Console.WriteLine(""); Console.WriteLine("###################### TWITTER PULL #########################"); Console.WriteLine(""); if (t.is_tag) { Console.WriteLine("Importing Records from Twitter for Hashtag #" + t.value); twitter_count = twitter_count + _twitter.fetch(t.value, fetch_count, ev.id, t.id); } else { Console.WriteLine("Importing Records from Twitter for Username @" + t.value); twitter_count = twitter_count + _twitter.fetch(t.value, fetch_count, true, ev.id, t.id); } } } total_count = instagram_count + twitter_count + facebook_count; Statistic s = new Statistic(); s.facebook = facebook_count; s.instagram = instagram_count; s.pulldate = DateTime.Now; s.total = total_count; s.twitter = twitter_count; s.event_id = ev.id; _stats.add(s); ev.last_update = DateTime.Now; _events.update(ev); Console.WriteLine(""); Console.WriteLine("######################## ENDING UPDATE FOR EVENT " + ev.title + " ########################"); } Console.WriteLine(""); Console.WriteLine("######################## ENDING UPDATE SEQUENCE ########################"); }
protected void update(object sender, EventArgs e) { Event ev = new Event(); Boolean is_update = false; if (Page.RouteData.Values["id"] != null) { is_update = true; ev = _events.@select(Convert.ToInt32(Page.RouteData.Values["id"] as string)); } ev.title = title.Text.ToString(); ev.client = client.Text.ToString(); ev.description = description.Text.ToString(); ev.address = address.Text.ToString(); ev.address2 = address2.Text.ToString(); ev.city = city.Text.ToString(); ev.state = state.Text.ToString(); ev.zip = zip.Text.ToString(); ev.country = country.SelectedValue.ToString(); ev.interval = Convert.ToInt32(listenSlider.Value); ev.moderate = moderate.Checked; interval = ev.interval.ToString(); if (background_1920.HasFile) { string path = Server.MapPath("~/uploads/"); string extension = Path.GetExtension(background_1920.FileName.ToString()); string unique = Guid.NewGuid().ToString(); background_1920.SaveAs(path + unique + extension); ev.background_1920 = unique + extension; } if (background_1280.HasFile) { string path = Server.MapPath("~/uploads/"); string extension = Path.GetExtension(background_1280.FileName.ToString()); string unique = Guid.NewGuid().ToString(); background_1280.SaveAs(path + unique + extension); ev.background_1280 = unique + extension; } if (!string.IsNullOrEmpty(start_date.Text.ToString()) && !string.IsNullOrEmpty(start_time.Text.ToString())) { ev.start = ((DateTime)Convert.ToDateTime(start_date.Text.ToString())).Date.Add(((DateTime)Convert.ToDateTime(start_time.Text.ToString())).TimeOfDay); } if (!string.IsNullOrEmpty(end_date.Text.ToString()) && !string.IsNullOrEmpty(end_time.Text.ToString())) { ev.end = ((DateTime)Convert.ToDateTime(end_date.Text.ToString())).Date.Add(((DateTime)Convert.ToDateTime(end_time.Text.ToString())).TimeOfDay); } var theaddress = ev.address + " " + ev.city + " " + ev.state + " " + ev.country; var requestUri = string.Format("http://maps.googleapis.com/maps/api/geocode/xml?address={0}&sensor=false", Uri.EscapeDataString(theaddress)); var request = WebRequest.Create(requestUri); var response = request.GetResponse(); var xdoc = XDocument.Load(response.GetResponseStream()); var result = xdoc.Element("GeocodeResponse").Element("result"); try { var locationElement = result.Element("geometry").Element("location"); ev.latitude = Convert.ToDecimal(locationElement.Element("lat").Value); ev.longitude = Convert.ToDecimal(locationElement.Element("lng").Value); } catch (NullReferenceException ex) { ev.latitude = null; ev.longitude = null; } if (is_update) { ev = _events.update(ev); } else { ev.created_by = Session["user_name"].ToString(); ev.created_date = DateTime.Now; ev.created_by_int = Convert.ToInt32(Session["user_id"].ToString()); ev = _events.add(ev); } ph_current_1280.Controls.Clear(); ph_current_1920.Controls.Clear(); if (!string.IsNullOrEmpty(ev.background_1280)) { ph_current_1280.Controls.Add(new LiteralControl("<h6>Current 1280 x 720 Background</h6><p><img src=\"/uploads/" + ev.background_1280 + "\" width=\"100%\" /></p>")); } if (!string.IsNullOrEmpty(ev.background_1920)) { ph_current_1920.Controls.Add(new LiteralControl("<h6>Current 1920 x 1280 Background</h6><p><img src=\"/uploads/" + ev.background_1920 + "\" width=\"100%\" /></p>")); } pnl_success.Visible = true; }