void client_GetCompleted(object sender, FacebookApiEventArgs e) { if (e.Error != null) { Dispatcher.BeginInvoke(() => MessageBox.Show(e.Error.Message)); return; } else { //SocialAccount account = new SocialAccount( //var result = (IDictionary<string, object>)e.GetResultData(); //var id = (string)result["id"]; FBUser userAccount = JsonConvert.DeserializeObject<FBUser>(e.GetResultData().ToString()); SocialAccount socialAccount = new SocialAccount(userAccount.id,client.AccessToken,userAccount.username,null); SettingHelper.SetKeyValue<SocialAccount>("SocialAccount",socialAccount); Dispatcher.BeginInvoke(() => { FacebookWebBrowser.Visibility = System.Windows.Visibility.Collapsed; StackPanelHeader.Visibility = System.Windows.Visibility.Visible; ContentPanel.Visibility = System.Windows.Visibility.Visible; }); } }
private void OnGetFriendsCompleted(object sender, FacebookApiEventArgs e) { RFBClient.GetCompleted -= new EventHandler<FacebookApiEventArgs>(OnGetFriendsCompleted); if (e.Error == null) { #if !DEBUG Stopwatch OStop = new Stopwatch(); Console.WriteLine("Friends Fetching Started .."); OStop.Start(); #endif var result = (IDictionary<string, object>)e.GetResultData(); //JsonArray ResultsArray = null; //JsonObject ResultsObject = e.GetResultData() as JsonObject; ObservableCollection<ProfileInfo> FriendList = new ObservableCollection<ProfileInfo>(); List<string> ids = new List<string>(); //if (Verifier.Verify(ResultsObject, "data")) // ResultsArray = ResultsObject["data"] as JsonArray; var dataItem = (JsonArray)result["data"]; foreach (JsonObject item in dataItem) { FriendList.Add(new ProfileInfo(item)); } foreach (var item in FriendList) { ids.Add(item.ID); } OnFriendListUpdated(FriendList); #if !DEBUG Console.WriteLine("Friends Fetching Finished in " + OStop.ElapsedMilliseconds); OStop.Stop(); #endif App.MManager.PublishMessageByType<FriendListMessage>(new FriendListMessage() { FriendIDList = ids }); } else { } }
public void fb_PostCompleted(object sender, FacebookApiEventArgs e) { if (e.Cancelled) { MessageBox.Show("Upload cancelled"); } else if (e.Error == null) { // upload successful. MessageBox.Show(e.GetResultData().ToString()); } else { // upload failed //MessageBox.Show(e.Error.Message); } progressBar1.BeginInvoke(new MethodInvoker(() => { progressBar1.Value = 0; })); }
private void OnGetEventsCompleted(object sender, FacebookApiEventArgs e) { RFBClient.GetCompleted -= new EventHandler<FacebookApiEventArgs>(OnGetEventsCompleted); if (e.Error == null) { #if !DEBUG Stopwatch OStop = new Stopwatch(); Console.WriteLine("Friends Fetching Started .."); OStop.Start(); #endif var result = (IDictionary<string, object>)e.GetResultData(); ObservableCollection<Event> FriendList = new ObservableCollection<Event>(); //if (Verifier.Verify(ResultsObject, "data")) // ResultsArray = ResultsObject["data"] as JsonArray; var dataItem = (JsonArray)result["data"]; foreach (JsonObject item in dataItem) { FriendList.Add(new Event(item)); } OnEventListUpdated(FriendList); #if !DEBUG Console.WriteLine("Friends Fetching Finished in " + OStop.ElapsedMilliseconds); OStop.Stop(); #endif //FinishedEvents.NotifyFriendsDataFinished(true, FriendList); } else { //FinishedEvents.NotifyFriendsDataFinished(false, null); } }
void RFBClient_PostCompleted(object sender, FacebookApiEventArgs e) { RFBClient.PostCompleted -= new EventHandler<FacebookApiEventArgs>(RFBClient_PostCompleted); if (e.Error == null) { #if !DEBUG Stopwatch OStop = new Stopwatch(); Console.WriteLine("Friends Fetching Started .."); OStop.Start(); #endif var result = (IDictionary<string, object>)e.GetResultData(); //if (Verifier.Verify(ResultsObject, "data")) // ResultsArray = ResultsObject["data"] as JsonArray; var id = result["id"] as string; OnNewEventCreated(id); #if !DEBUG Console.WriteLine("Friends Fetching Finished in " + OStop.ElapsedMilliseconds); OStop.Stop(); #endif //FinishedEvents.NotifyFriendsDataFinished(true, FriendList); } else { //FinishedEvents.NotifyFriendsDataFinished(false, null); } }
private void client_GetCompleted(object sender, FacebookApiEventArgs e) { dynamic items = dataGridFriendsEvents.ItemsSource ?? new List<GamingEvent>(); dynamic result = e.GetResultData(); Event eEvent = (Event)e.UserState; GamingEvent gEvent = new GamingEvent(); gEvent.Event = eEvent; if(result.description != null) gEvent.Description = result.description.ToString(); if(result.end_time != null) gEvent.EndTime = DateTime.Parse(result.end_time.ToString()); if (result.start_time != null) gEvent.StartTime = DateTime.Parse(result.start_time.ToString()); if (result.name != null) gEvent.Name = result.name.ToString(); if (result.location != null) gEvent.Location = result.location.ToString(); items.Add(gEvent); dataGridFriendsEvents.ItemsSource = items; }
void client_GetCompleted(object sender, FacebookApiEventArgs e) { if (e.Error == null) { //Success resultsList.Add(e.GetResultData<JsonArray>()); UpdateProgress(); if (Parameters.Count > 0) ExecuteBatch(); else { List<FriendsEdgeStruct> EdgeList = ParseResults(resultsList, friendsList); RemoveDuplicates(EdgeList); //Done } } else { //Error Debug.WriteLine(e.Error.Message); throw e.Error; } }
private void facebookClient_PostCompleted(object sender, FacebookApiEventArgs e) { Logger.Info("Called"); if (e.Cancelled) { Logger.Info("Cancelled"); PublishWorkerResult = PublishWorkerResults.Cancelled; } else if (e.Error != null) { Logger.Error("Error uploading: " + e.Error); ErrorMessage = e.Error.ToString(); PublishWorkerResult = PublishWorkerResults.UnableToShare; } else { /* format: { "id": "xxxxx19208xxxxx" } */ string jsonResponse = e.GetResultData().ToString(); Logger.Info("Response from Facebook: " + jsonResponse); var structuredResponse = (FacebookJSONResponse)facebookClient.DeserializeJson(jsonResponse, typeof(FacebookJSONResponse)); /* This works, but it requires extra assemblies var ser = new DataContractJsonSerializer(typeof(FacebookJSONResponse)); var stream = new MemoryStream(Encoding.UTF8.GetBytes(jsonResponse)); var structuredResponse = (FacebookJSONResponse)ser.ReadObject(stream); stream.Close(); */ Logger.Info("FacebookActivityId = " + structuredResponse.id); HighlightObject.FacebookActivityId = structuredResponse.id; PublishWorkerResult = PublishWorkerResults.Success; } uploadCompleted = true; }
void client_GetCompleted(object sender, FacebookApiEventArgs e) { UserInfoStruct UserInfo = new UserInfoStruct(); if (e.Error == null) { //Success JsonArray ResultsArray = (JsonArray)e.GetResultData(); UserInfo = ParseResults(ResultsArray); //Event if (GetUserInfo_Complete != null) GetUserInfo_Complete.Invoke(this, new GetUserInfoEventArgs(UserInfo, true, null)); } else { //Error, Event if (GetUserInfo_Complete != null) GetUserInfo_Complete.Invoke(this, new GetUserInfoEventArgs(UserInfo, false, e.Error)); } }
private void fb_PostCompleted(object sender, FacebookApiEventArgs e) { if (e.Cancelled) { var cancellationError = e.Error; MessageBox.Show("Upload unterbrochen"); } else if (e.Error == null) { // upload successful. MessageBox.Show(e.GetResultData().ToString()); } else { // upload failed MessageBox.Show(e.Error.Message); } }
/// <summary> /// will be called when the data is ready from facebook /// <summary> void _fbClient_GetCompleted(object sender, FacebookApiEventArgs e) { IDictionary<string, object> result = (IDictionary<string, object>)e.GetResultData(); Deployment.Current.Dispatcher.BeginInvoke(() => { (e.UserState as Action<IDictionary<string, object>>)(result); }); }
void client_GetCompleted(object sender, FacebookApiEventArgs e) { List<long> FriendsList = new List<long>(); Dictionary<long, FriendsInfoStruct> FriendsInfo = new Dictionary<long,FriendsInfoStruct>(); if (e.Error == null) { //Success JsonArray ResultsArray = (JsonArray)e.GetResultData(); FriendsInfo = ParseResults(ResultsArray); foreach (KeyValuePair<long, FriendsInfoStruct> kvp in FriendsInfo) { FriendsList.Add(kvp.Key); } //Event if (GetFriendsInfo_Complete != null) GetFriendsInfo_Complete.Invoke(this, new GetFriendsInfoEventArgs(FriendsList, FriendsInfo, true, null)); } else { //Error, Event if (GetFriendsInfo_Complete != null) GetFriendsInfo_Complete.Invoke(this, new GetFriendsInfoEventArgs(FriendsList, FriendsInfo, false, e.Error)); } }
private void onMessageSentCompletion(object sender, FacebookApiEventArgs e) { try { var a = App.Current as App; if (e.Error == null) { var result = (IDictionary<string, object>)e.GetResultData(); var model = new List<Place>(); foreach (var place in (JsonArray)result["data"]) model.Add(new Place() { Id = (string)(((JsonObject)place)["id"]), Name = (string)(((JsonObject)place)["name"]) }); FacebookClient fb = new FacebookClient(_facebookToken); var param = new Dictionary<string, object> { { "message", "I am in danger at :" }, { "place", model.FirstOrDefault().Id }, {"acess_token",_facebookToken}, {"privacy", new Dictionary<string, object>{{"value", "ALL_FRIENDS"}}}}; // Posting status on facebook fb.PostTaskAsync("me/feed", param, new System.Threading.CancellationToken()); // Calling method to send sms SMSUtils smsmUtil = new SMSUtils(); smsmUtil.SendText(GetSavedNumbers(), "I am in danger at :" + model.FirstOrDefault().Name); } else { Deployment.Current.Dispatcher.BeginInvoke(() => { MessageBox.Show("Error ocurred in sending messages " + e.Error.Message); }); } } catch (System.Net.WebException ex) { MessageBox.Show("Internet connection is not working : " + ex.Message); } catch (System.Exception ex) { MessageBox.Show("Error while posting status in facebook : " + ex.Message); } }
private static void HandleGetCompleted(object sender, FacebookApiEventArgs e) { var callback = e.UserState as FacebookDelegate; if (callback != null) { var result = new FBResult(); if (e.Cancelled) result.Error = "Cancelled"; else if (e.Error != null) result.Error = e.Error.Message; else { var obj = e.GetResultData(); result.Text = obj.ToString(); result.Json = obj as JsonObject; } Dispatcher.InvokeOnAppThread(() => { callback(result); }); } }
void client_GetCompleted(object sender, FacebookApiEventArgs e) { if (e.Error == null) { resultsRecieved++; UpdateProgress(); //Success JsonArray results = e.GetResultData<JsonArray>(); ParseResults(results); //If we need another page the run it, continue if (resultsRecieved >= pageTotal) { #if DEBUG RunMetrics(); #endif TimeSpan duration = DateTime.Now - StartTime; core.Analytics.SendMetric(core.Analytics.Metric.MapTime, duration.Seconds); core.Analytics.SendMetric(core.Analytics.Metric.MaxReturnFQL, MaxFqlReturnSize); core.Analytics.SendMetric(core.Analytics.Metric.Edges, EdgeNum); ApiComplete(FriendsMap); } } else { //Error Debug.WriteLine(e.Error.Message); throw e.Error; } }
public void fb_PostCompleted(object sender, FacebookApiEventArgs e) { picStatus.Visible = false; btnUpload.Tag = 0; btnUpload.Text = GlobalSetting.LangPack.Items["frmFacebook.btnUpload._Upload"]; if (e.Cancelled) { lblStatus.Text = GlobalSetting.LangPack.Items["frmFacebook._StatusCancel"]; } else if (e.Error == null) { // upload successful. lblStatus.Text = GlobalSetting.LangPack.Items["frmFacebook._StatusSuccessful"]; btnUpload.Tag = e.GetResultData().ToString().Substring(7, 15);//Get Post ID btnUpload.Text = GlobalSetting.LangPack.Items["frmFacebook.btnUpload._ViewImage"]; } else { // upload failed lblStatus.Text = e.Error.Message; } }
/// <summary> /// Called whenever we get feeds from facebook /// </summary> private void fb_GetCompleted(object sender, FacebookApiEventArgs e) { // Handle feeds retreival error if (e.Error != null) { System.Diagnostics.Debug.WriteLine(e.Error.Message); IsUpdating = false; OnRaiseFeedsEvent(new SocialLinkEventArgs(e.Error.Message)); return; } // Parse json results to facebook feeds parseRawData(e.GetResultData().ToString()); // Save data for persistence. if (CurrentAction == FeedAction.New) lastRawData = e.GetResultData().ToString(); }