I've written a entry form for our company employees to enter marketing courses into the DB and at the same time add them to a Google Calendar. The Calendar is accepting the events, but the coloration of the event is different from a "manually" entered event using Google's interface. This leads me to believe that there is some property I am not setting that is causing the events not to be show on the calendar once it is embedded in our other company web pages.
The code used to enter events:
// Create a CalenderService and authenticate
CalendarService myService = new CalendarService("exampleCo-exampleApp-1");
myService.setUserCredentials("xxx#gmail.com", "xxxxxx");
CalendarQuery query = new CalendarQuery();
query.Uri = new Uri("https://www.google.com/calendar/feeds/default/owncalendars/full");
CalendarFeed resultFeed = (CalendarFeed)myService.Query(query);
Uri postUri = new Uri("https://www.google.com/calendar/feeds/default/owncalendars/full");
foreach (CalendarEntry centry in resultFeed.Entries)
{
litErrorMsg.Text += centry.Title.Text + "<br />";
if (centry.Title.Text == "fmicoursecalendar#gmail.com")
{
postUri = new Uri("https://www.google.com/calendar/feeds/" +
centry.SelfUri.ToString().Substring(centry.SelfUri.
ToString().LastIndexOf("/") + 1) + "/private/full");
break;
}
}
Google.GData.Calendar.EventEntry entry = new Google.GData.Calendar.EventEntry();
// Set the title and content of the entry.
entry.Title.Text = eventName;
entry.Content.Content = eventName;
//entry.QuickAdd = true;
entry.EventVisibility = new Google.GData.Calendar.EventEntry.Visibility("event.public");
When eventTime = new When(Convert.ToDateTime(startDate), Convert.ToDateTime(endDate));
entry.Times.Add(eventTime);
GDataGAuthRequestFactory requestFactory = (GDataGAuthRequestFactory)myService.RequestFactory;
requestFactory.CreateRequest(GDataRequestType.Insert, postUri);
// Send the request and receive the response:
AtomEntry insertedEntry = myService.Insert(postUri, entry);
And this is the resulting calendar:
The "test event jasdf event" is the manually entered event, and the two events: "Test event 234" are the programmatically entered events. In any case, once I embed the calendar, the only event showing up is the "test event jasdf".
I tried to manually set the event to PUBLIC but that didn't seem to help.
Anyone faced this issue before or had success with google calendar? If so, I'd like to see what you might have used to successfully create events and publish them.
Thanks!
Tom -
Have you figured this issue out yet? I'm thinking that you might be adding events to the wrong calendar... this would explain both of your problems:
The events are colored differently because you're viewing multiple calendars simultaneously, and Google Calendar uses different colors for each calendar.
Once you embed the single calendar that you think contains the events, you're only seeing the events that are actually on that specific calendar... hence, none of the events which were incorrectly placed.
The key here would be to check exactly which calendars you're viewing in the Google Calendar interface, and then look to see where the programmatically inserted events are ending up.
Related
I am using Firesharp for my app in c# winforms. This database is also connected to my ReactJS website which deals with the same information.
I have noticed that when I make .SetAsync calls to my app on the website and then log in to my Winforms app, my WinForms app will automatically perform the last action I did on my website to my database which is a .setAsync() action which adds some user information to a list of other user's information. Now it will not stop. Anytime I log on to my c# app, it runs it.
It makes me think there is a queue of orders in firesharp?
here is my react code. From what I can tell, it is nothing out of the ordinary:
async function handleSubmit(e) {
e.preventDefault()
var date = moment().format("MM/DD/YYYY" )
setError("")
setLoading(true)
// grab user info first then use that.
await firebaseApp.database().ref("Users/" + currentUser.uid + "/UserData").on('value', snapshot => {
if (snapshot.val() != null) {
setContactObjects({
...snapshot.val()
})
firebaseApp.database().ref("Projects/" + projectGUIDRef.current.value + "/queueList/" + userIdRef.current.value).set({
"EntryTimeStamp": date + " " + moment().format("hh:mm:ss a"),
"IsSyncing": false,
"UserId": userIdRef.current.value,
"UserName": usernameRef.current.value,
})
}
})
history.push("/Demo")
setLoading(false)
}
here is my c# winforms code of where the code is executing. For some reason, when this executes, it also updates the EntryTimeStamp field of the react code and completely sets all the information even if I delete it. It also happens if I run .set().
updateLastLogin2(authLink);
private async void updateLastLogin2(FirebaseAuthLink authLink)
{
IFirebaseConfig config = new FireSharp.Config.FirebaseConfig
{
AuthSecret = this.authLink.FirebaseToken,
BasePath = Command.dbURL,
};
IFirebaseClient client = new FireSharp.FirebaseClient(config);
string newDateTime = DateTime.Now.ToString();
if (authLink.User.DisplayName.Contains(adUserId) && authLink.User.DisplayName.Contains(adUserId))
{
await client.SetAsync("Users/" + this.authLink.User.LocalId + "/UserData/DateLastLogin", newDateTime);
}
}
Any and all help is appreciated, I've been at this for a day and a half now.
I have never used fire-sharp but this is my guess
You are calling await firebaseApp.database().ref("Users/" + currentUser.uid + "/UserData").on('value' in your react, and then in your Csharp you are calling client.SetAsync("Users/" + this.authLink.User.LocalId .
What happens is the both listeners are listening to each other and then causing a loop.
In that case it's probably better to use once instead of on if you are just using it once.
In cases where you cannot use .once, then you should use .off to turn off the listener once you are done.
firebaseApp.database().ref("Users/" + currentUser.uid + "/UserData").once('value'`
You also shouldn't be using await here since ref().on creates a listener, it doesn't return a promise.
You should also move history.push("/Demo") into your firebase database callback function so it's called after you have set data
Is there a way to get the whole Facebook friends list using an api!
I've tried a lot of thing and here's my shot:
FacebookClient f = new FacebookClient(access_token);
f.IsSecureConnection = true;
dynamic friendlist = await f.GetTaskAsync(#"https://graph.facebook.com/me/friendlists?access_token="+access_token);
t.Text = JsonConvert.SerializeObject(friendlist);
But all I got is an empty data!
Can anyone help me?
The friendlists endpoint is deprecated, as you can see in the breaking changes log: https://developers.facebook.com/docs/graph-api/changelog/breaking-changes#tagged-users-4-4
It would not have been what you expected anyway, it was only for lists, not friends directly. Access to all friends is not possible since a very long time. You can only get data of users/friends who authorized your App. You can use the /me/friends endpoint for that.
Another thread about getting all friends: Facebook Graph API v2.0+ - /me/friends returns empty, or only friends who also use my application
There is another way can give you an access to your all friend list names by downloading a copy of your facebook information data by selecting friends and following checkbox and wait till your file is ready then download it.
This is not the API way but for starters who want one time download list of friends
Go to the friend list page: https://www.facebook.com/friends/list
Scroll all the way down so that all friend list loads
Press F12 to open developer tools, click on console tab
A. Show in console
copy paste following script in console and hit enter.
var accumulated = "";
for (var el of document.querySelectorAll('[data-visualcompletion="ignore-dynamic"]')) {
var name = el.getAttribute("aria-label");
if(name!= null && name != "null"){
accumulated = "Name:"+name +", "+ accumulated;
console.log(accumulated);
accumulated = "";
}else{
var a = el.getElementsByTagName("a")[0];
if(a){
accumulated += "Profile URL: "+ a.getAttribute("href");
//console.log(a);
}
}
}
B. Download a .json file
copy paste following script in console and hit enter.
var exportObj = [];
var accumulated = "";
for (var el of document.querySelectorAll('[data-visualcompletion="ignore-dynamic"]')) {
var name = el.getAttribute("aria-label");
if(name!= null && name != "null"){
exportObj.push({name: name, profileURL: accumulated});
accumulated = "";
}else{
var a = el.getElementsByTagName("a")[0];
if(a){
accumulated += a.getAttribute("href");
}
}
}
var dataStr = "data:text/json;charset=utf-8," + encodeURIComponent(JSON.stringify(exportObj));
var downloadAnchorNode = document.createElement('a');
downloadAnchorNode.setAttribute("href", dataStr);
downloadAnchorNode.setAttribute("download", "friendsList.json");
document.body.appendChild(downloadAnchorNode);
downloadAnchorNode.click();
downloadAnchorNode.remove();
Note: pseudo code tested in firefox
I'm working on a web browser where the default search engine is Google until the user clicks on the Yahoo (or another search engine) button. The problem is, after you start a new session, it opens with Google again. How to you save that?
I'm aware how to save settings with Properties.Settings.Default.Save(); however it doesn't seem to work with a click event. (Where the code is to change the search engine)
I'm using GeckoFX. Code for the Yahoo setting is:
goo.Enabled = true;
y.Enabled = false;
bin.Enabled = true;
ba.Enabled = true;
ya.Enabled = true;
sear.Text = "Yahoo!";
And is performed with:
if (y.Enabled == false)
{
W.Navigate("search.yahoo.com/search?p=" + q.Text);
W.Select();
}
I have an event receiver that is using the ItemUpdating event. I am trying to disinherit the item's permissions from parent and strip all permissions on the item upon being uploaded to the Drop Off Library. The reason for this is that the document contains sensitive information and should not be visible to anyone once it arrives in the Drop Off Library.
The code below is throwing the following error when executing the CurrentListItem.BreakRoleInheritence(true) line upon reaching the Drop Off Library: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (SPSite oSiteCollection = new SPSite(properties.ListItem.Web.Url))
{
using (SPWeb oWebsite = oSiteCollection.RootWeb)
{
SPListItem CurrentListItem = properties.ListItem;
SPRoleAssignmentCollection SPRoleAssColn = CurrentListItem.RoleAssignments;
oSiteCollection.AllowUnsafeUpdates = true;
oWebsite.AllowUnsafeUpdates = true;
CurrentListItem.BreakRoleInheritance(true);
oSiteCollection.AllowUnsafeUpdates = true;
oWebsite.AllowUnsafeUpdates = true;
for (int i = SPRoleAssColn.Count - 1; i >= 0; i--)
{
if (SPRoleAssColn[i].Member.Name != "System Account")
{
SPRoleAssColn.Remove(i);
}
}
}
}
});
I have also done the following things:
- made sure the Identity of the app pool is a site collection admin
- tried to get the list item again using GetItemById (but this throws an error that the item does not exist, since the item has still not been published yet - we need to remove permissions before the document is published - and we cannot force a check-in otherwise the drop off library might process and move the document to the its target library)
- tried getting the web and site options using guids
- tried many different combinations of placements with AllowUnsafeUpdates
- used the user token of a site collection admin to open the web objects
For some reason, the code above works fine when the document reaches the target library (as we are removing all the permissions AGAIN once the document arrives at the destination). This happens because the document is moved from the drop off library to the target library using the System Account.
Any thoughts on how to get around the "Access is Denied" error while utilizing a similar approach as above?
And how this item is being sent to Drop off library? Via workflow, or when using OfficialFile.asmx? Can you check if this eventreceiver works properly when you manually upload file (most probably you will have to click 'submit' to force update, but maybe you can set fields in such way, that none of your Rules would match? I files get there via workflow, make sure that also account on which SPTimer4 service is running is site administrator on this site collection.
Also be careful, - i think there are two things that may not work as you expect in your event receiver:
SPSecurity.RunWithElevatedPrivileges(delegate()
{
using (var oSiteCollection = new SPSite(properties.ListItem.Web.Url))
{
using (var oWebsite = oSiteCollection.RootWeb)
{
var currentListItem = properties.ListItem;
oSiteCollection.AllowUnsafeUpdates = true;
oWebsite.AllowUnsafeUpdates = true;
currentListItem.BreakRoleInheritance(true);
//You should take the RoleAssignments after breaking inheritance our you will be working on parents permissions.
var spRoleAssColn = currentListItem.RoleAssignments;
oSiteCollection.AllowUnsafeUpdates = true;
oWebsite.AllowUnsafeUpdates = true;
for (int i = spRoleAssColn.Count - 1; i >= 0; i--)
{
//I think it won't allow you to remove permissions for site administrator
if (spRoleAssColn[i].Member.Name != "System Account" && !oWebsite.EnsureUser(spRoleAssColn[i].Member.LoginName).IsSiteAdmin)
{
spRoleAssColn.Remove(i);
}
}
}
}
});
I'm trying to intercept tapping on a link in a WebBrowser control.
My HTML page contains custom links, for some starting with shared:// I'd like to intercept when the user tap on it.
On iPhone I would use the webView:shouldStartLoadWithRequest:navigationType: method, and look at the URL that is selected.
I haven't managed to reproduce a similar behaviour with Silverlight for Windows Phone.
I do something like:
{
webBrowser1.Navigating += new EventHandler<NavigatingEventArgs>(webBrowser1_Navigating);
}
void webBrowser1_Navigating(object sender, NavigatingEventArgs e)
{
string scheme = null;
try
{
scheme = e.Uri.Scheme; // <- this is throwing an exception here
}
catch
{
}
if (scheme == null || scheme == "file")
return;
// Not going to follow any other link
e.Cancel = true;
if (scheme == "shared")
{
}
But I guess an exception when reading some properties of the Uri, when it's a standard Uri with a default file:// URL
Additionally, the Navigating event isn't even triggered for links starting with shared://
Now that I'm able to capture tapping on a shared:// I do not care much, but at least I'd like to be able to retrieve the URL we're going to navigate to, and cancel the default operation for a particular URL.
Any ideas what's going on?
Thanks
Edit:
It turned out that the problem is that the Navigating event is only generated for the following links: file://, http:// or mailto://
The scheme attributes of the Uri is only available for the http:// and mailto:// links
so what I did in the end is replace the shared:// link with http://shared/blah ... And I look at the URL... This works for my purpose. I can now have links that have a different action (like opening an extra window) depending on the links in the html.
Here is my final code, in case this is useful for someone in the future:
For an about screen, I use an html file displayed in a WebBrowser component.
The about page has a "tell your friend about this app" link as well as links to external web site.
It also has local subpages.
Local sub-pages are linked to using a file:// link. Those can be navigated within the WebBrowser component.
External links are opened externally with Internet Explorer.
Tell your friend link is made of a http://shared link, that opens an email with a pre-set subject and body. Unfortunately, no other scheme than the standard ones are usable as they do not trigger a Navigating event
There's also a support link which is a mailto:// link and opens an EmailComposeTask
void webBrowser1_Navigating(object sender, NavigatingEventArgs e)
{
String scheme = null;
try
{
scheme = e.Uri.Scheme;
}
catch
{
}
if (scheme == null || scheme == "file")
return;
// Not going to follow any other link
e.Cancel = true;
if (scheme == "http")
{
// Check if it's the "shared" URL
if (e.Uri.Host == "shared")
{
// Start email
EmailComposeTask emailComposeTask = new EmailComposeTask();
emailComposeTask.Subject = "Sharing an app with you";
emailComposeTask.Body = "You may like this app...";
emailComposeTask.Show();
}
else
{
// start it in Internet Explorer
WebBrowserTask webBrowserTask = new WebBrowserTask();
webBrowserTask.Uri = new Uri(e.Uri.AbsoluteUri);
webBrowserTask.Show();
}
}
if (scheme == "mailto")
{
EmailComposeTask emailComposeTask = new EmailComposeTask();
emailComposeTask.To = e.Uri.AbsoluteUri;
emailComposeTask.Show();
}
}