Unable to connect to Microsoft band from Background Task - microsoft-band

I'm using MS Band SDK version 1.3.10518, when I try to init the band client from Background Task I got:
BACKGROUNDTASKHOST.EXE' has exited with code 1
The crash happens after the following line of code:
Dim bands = Await Microsoft.Band.BandClientManager.Instance.GetBandsAsync()
I'm able to connect to the band from the main application on windows phone 8.1 developer preview.
Band Build Version: 10.3.3213.0 09 R

I found the solution related to Await in the Sub Run, the solution consists of using : taskInstance.GetDeferral
Public Async Sub Run(taskInstance As Background.IBackgroundTaskInstance) Implements Background.IBackgroundTask.Run
Dim deferral = taskInstance.GetDeferral
Dim bands = Await Microsoft.Band.BandClientManager.Instance.GetBandsAsync
'Other work ...
End Using
deferral.Complete()
End Sub
In addition you need to get user consent from the main application as follow:
bandClient.SensorManager.HeartRate.GetCurrentUserConsent
Thanks for: HttpClient GetAsync fails in background task on Windows 8

Related

Calling Microsoft graph API from dotnetcore app returns NotFound

I'm trying to get items from SharePoint using the Graph API in the name of the user, all these done inside a .net core 3.1 web app using oauth. When I request for specific items in a SharePoint document library I get the following ServiceException:
ex = {"Code: itemNotFound\r\nMessage: The resource could not be found.\r\nInner error:\r\n\tAdditionalData:\r\n\trequest-id: 7605d475-5967-481e-a16c-ab1fad610ef9\r\n\tdate: 2020-04-15T21:27:48\r\nClientRequestId: 7605d475-5967-481e-a16c-ab1fad610ef9\r\n"}
My calling function is the following:
var searchResult = await graphServiceClient
.Sites[$"{SharePointSiteId}"]
.Drives[$"{SharePointDocumentLibraryId}"]
.Items[$"{InvoicesFolderId}"]
.Children
.Request()
.GetAsync();
where:
SharePointSiteId is a fully qualified SPS site Id
SharePointDocumentLibraryId id of the document library
InvoicesFolderId id of the folder in which I'd like to enumerate the children elements
The strange is that until I request for the Drive only:
var searchResult = await graphServiceClient
.Sites[$"{SharePointSiteId}"]
.Drives[$"{SharePointDocumentLibraryId}"]
.Request()
.GetAsync();
everything goes fine.
Strange thing 2: If I call the API using the Graph explorer with the same user in the same time using the Item identifier {InvoicesFolderId}, it gives back its children well.
Needless to say, the user can login to the SPS site and do whatever she wants. :)
I am able to reproduce the same exception thrown when calling from Graph .Net SDK in C#. Taking the exact same URL that is generated by SDK and testing in Graph Explorer is successful as well. I would recommend opening an issue on the Graph .Net SDK repo.

Evernote SetSharedSessionConsumerKey Does not Work in Outlook VBA Macro

I have a VBA macro in Outlook that moves a selected message into my archive folder and gets a url for the message. I also would like to add the message to Evernote like the "Save to Evernote" add-in and automatically add the url to the message as the url of the note.
I downloaded the COM setup for the Evernote Cloud SDK:
https://github.com/evernote/evernote-cloud-sdk-windows/tree/master/COM%20Setup
I then registered for and received my Evernote API Key for this application (Consumer Key and Consumer Secret).
I have an account in the sandbox.
I added a reference to the Evernote Cloud SDK and wrote some simple code to test that it is working.
However, the following code fails when checking the SharedSession.IsAuthenticated.
The code:
Public Sub CreateNote()
Const Key = "MY KEY"
Const Secret = "MY SECRET"
Const Host = "sandbox.evernote.com"
Dim evernoteSession As New ENSessionForCOM
Call evernoteSession.SetSharedSessionConsumerKey(Key, Secret, Host)
If evernoteSession.SharedSession.IsAuthenticated = False Then
evernoteSession.SharedSession.AuthenticateToEvernote
End If
End Sub
The error:
Run-time error '-2147024809 (80070057)'
Cannot create shared Evernote session without either a valid
consumer key/secret pair, or a developer token set.
I thought maybe I was trying too soon, but it has been almost 24 hours. What am I doing wrong?
After a lot of trial and error, I finally found a solution. Instead of an ENSessionForCOM, I needed to create an ENSessionAdvancedForCOM object. So now the code looks like this:
Public Sub CreateNote()
Const Key = "MY KEY"
Const Secret = "MY SECRET"
Const Host = "sandbox.evernote.com"
Dim evernoteSession As New ENSessionAdvancedForCOM
Call evernoteSession.SetSharedSessionConsumerKey(Key, Secret, Host)
If evernoteSession.SharedSession.IsAuthenticated = False Then
evernoteSession.SharedSession.AuthenticateToEvernote
End If
End Sub
And it now authenticated.

Signalr send message from browser to .net client on the same machine

We need to communicate a native application with a web application.
We think to use signalr to send the message/command.
The pipeline would be:
User clicks to make an action.
Javascript (with signalr) send a message to a server in azure.
The server re-send the message a specific client. It must be the client installed on the same machine.
Once the result is completed, NET sends the resulting reverse.
The matter is, How I can find client from the same machine in the signalr Server?
The organization in our system is:
There is center/gym.
Every center has staff who can login.
We could identify client at the same center with some file configuration. Saving our key center, for example. But, in a center, could there are more than one.NET client installed on the different computer.
We think to use the private IP of the computer to make a key on the signalr server.
var ips = [];
var RTCPeerConnection = window.RTCPeerConnection ||
window.webkitRTCPeerConnection || window.mozRTCPeerConnection;
var pc = new RTCPeerConnection({
// Don't specify any stun/turn servers, otherwise you will
// also find your public IP addresses.
iceServers: []
});
// Add a media line, this is needed to activate candidate gathering.
pc.createDataChannel('');
// onicecandidate is triggered whenever a candidate has been found.
pc.onicecandidate = function (e) {
if (!e.candidate) { // Candidate gathering completed.
pc.close();
console.log(ips);
return;
}
var ip = /^candidate:.+ (\S+) \d+ typ/.exec(e.candidate.candidate)[1];
ips.push(ip);
};
pc.createOffer(function (sdp) {
pc.setLocalDescription(sdp);
}, function onerror() { });
This data can be obtained in .NET client without a problem. But in javascript, the previous code works regularly. In some PC, it only returns ipv4. And in Mozilla it doesn't work.
How can we identify both clients? Do You know another way to reach the goal?
Thanks,
Finally, we didn't find a good solution filtering ip adress.
We did the as follow:
We used URI schema to launch our app. URI Schema windows
Public Class RegistrarURI
Const URI_SCHEME As String = "xxx"
Const URI_KEY As String = "URL:xxx"
Private Shared APP_PATH As String = Location.AssemblyDirectory() ' "C:\Program Files (x86)\xxx.exe"
Public Shared Sub RegisterUriScheme()
Using hkcrClass As RegistryKey = Registry.ClassesRoot.CreateSubKey(URI_SCHEME)
hkcrClass.SetValue(Nothing, URI_KEY)
hkcrClass.SetValue("URL Protocol", [String].Empty, RegistryValueKind.[String])
Using defaultIcon As RegistryKey = hkcrClass.CreateSubKey("DefaultIcon")
Dim iconValue As String = [String].Format("""{0}"",0", APP_PATH)
defaultIcon.SetValue(Nothing, iconValue)
End Using
Using shell As RegistryKey = hkcrClass.CreateSubKey("shell")
Using open As RegistryKey = shell.CreateSubKey("open")
Using command As RegistryKey = open.CreateSubKey("command")
Dim cmdValue As String = [String].Format("""{0}"" ""%1""", APP_PATH)
command.SetValue(Nothing, cmdValue)
End Using
End Using
End Using
End Using
End Sub
End Class
In an Azure WebApp we launch a SignalR Server. This server will send data from our .NET app to Chrome.
To achive that, when the web is loaded, we connect to the signalR server. To build de uri, We send the connectionId from Javascript client to the .NET Client.
Then, when the native process is completed. .NET client send the information to signalR server, and this server mirrored the data to javacript client using the connectionId.
To avoid launch some instance of our native app, we use IPC channel to send data to one instance to the previous and closind the new one.
Link to source Blog source

Adding appointment to outlook using asp.net

I am developing a web application in asp.net web forms framework. one of the requirement of application is to save records of future appointments of user. User also want to add this appointment to his outlook calendar. Now the problem is that my code is working locally. Appointments are being saved when I test application on my local machine. But when I deploy application on live server code give error and appointment do not saves in my outlook calendar. Kindly help me how to make it work on live server. Following is the code I'm using
Private Sub AddToCalander()
Try
Dim olApp As Microsoft.Office.Interop.Outlook._Application = DirectCast(New Microsoft.Office.Interop.Outlook.Application(), Microsoft.Office.Interop.Outlook._Application)
Dim mapiNS As Microsoft.Office.Interop.Outlook.NameSpace = olApp.GetNamespace("MAPI")
Dim profile As String = ""
mapiNS.Logon(profile, Nothing, Nothing, Nothing)
Dim apt As Microsoft.Office.Interop.Outlook._AppointmentItem = DirectCast(olApp.CreateItem(Microsoft.Office.Interop.Outlook.OlItemType.olAppointmentItem), Microsoft.Office.Interop.Outlook._AppointmentItem)
apt.Subject = ddItineraryItems.SelectedItem.Text
apt.Body = txtPItinerary_Desc.Text
apt.Start = CDate(txtDateFromPopup.Text)
apt.End = CDate(txtDateToPopup.Text)
apt.BusyStatus = Microsoft.Office.Interop.Outlook.OlBusyStatus.olTentative
apt.AllDayEvent = False
apt.Location = dcmbDealer.SelectedItem.Text & "," & dcmbShowroom.SelectedItem.Text
apt.Save()
Catch ex As Exception
AlertMessage.showError("Unable to add itinerary detail to outlook calendar")
Exit Sub
End Try
End Sub
I get the code from here.
http://www.codeproject.com/Tips/384326/Add-to-Calender-Adding-event-to-Microsoft-Outlook
If you are going to use Outlook by Interop, then you would need to install it on your server. Without installed Outlook - it won't work.
PS. Your code will work only with Outlook account that is configured by default. And it will work only if you are using external service for appointments. Otherwise it will save that appointment just to Outlook on server, without updating it to your local Outlook
And using Interop in web applications on server side isn't a good idea, as it will starts new Outlook process every time, that is very resource expensive. Better way is to integrate with Calendar system that you are using, like Google Calendar, etc.

SEND OBJECT isn't available for one User in a Spilt-database

I have one User getting an error message in a MS ACCESS split database. The message is "The command or action "Send Object" isn't available now." The User gets this message when they are clicking on a command button that is suppose to open GroupWise e-mail and copy text from a MSACCESS form and have the TO: FROM: and SUBJECT: lines auto-populate.
I looked at the USER's Internet Explorer settings.
I checked to see if the USER has the most recent MS JET 4.0
I provided another copy of the front-end to save to the desktop
All other Users are not experiencing this problem. I must also add that this specific User was recently upgraded to MS OFFICE 2010, like the rest of us... Any suggestions ? Thanks
For anyone passing by on Google, this worked for me. The affected users had recently upgraded to Windows 7 with 32-bit Office 2010 (although some had upgraded without issue). It also works on my local machine (Windows 7 with 64-bit Office 2010).
Instead of using DoCmd.SendObject(....):
Sub SendMail()
Dim myOb As Object
Dim AutoSend as boolean
Set myOb = CreateObject("Outlook.Application")
Set oMail = myOb.CreateItem(olMailItem)
//Set whether to send email automatically or make user press Send
AutoSend = False
With oMail
.Body = "Message text"
.Subject = "Subject line"
.To = To#example.com
.cc = cc#example.com
If AutoSend Then
.send
Else
.display
End If
End With
Set oMail = Nothing
Set oApp = Nothing
End Sub

Resources