I'm writing a simple C# application that answers a Lync call and depending on a database value, forwards it to another phone number. That works perfectly. However, sometimes I want to forward the call to the user's voicemail. I can't figure out how to get the URI for the voicemail box :(
Assuming I'm in the handler for a ConversationAdded event. I've tried this:
Conversation conv = args.Conversation;
string voicemailURI = String.Format("{0};opaque=app:voicemail",conv.SelfParticipant.Contact.Uri);
// the contact returned here, however, does not contain the opaque=app:voicemail
Contact forwardContact = lync.ContactManager.GetContactByUri(voicemailURI);
Also:
Conversation conv = args.Conversation;
// following throws ArgumentException: Value does not fall within the expected range
Phone voicemail = lync.Self.GetPhone(ContactEndpointType.VoiceMail);
string voicemailURI = voicemail.Endpoint.Uri
Contact forwardContact = lync.ContactManager.GetContactByUri(voicemailURI);
UC voicemail is setup and working otherwise. I'm not sure what the term is exactly, but it's handled by Exchange and the messages appear in my Inbox. If I just let the phone ring it will eventually end up in voicemail, but my app knows it should go there right away so I'd like to forward it immediately.
I guess I'm not quite sure why you care about getting the contact? Your first example will give you the URI to go directly to voicemail. At that point you can just do this:
var automation = LyncClient.GetAutomation();
var conversationModes = AutomationModalities.Audio;
var conversationSettings = new Dictionary<AutomationModalitySettings, object>();
List<string> participants = new List<string>();
Conversation conv = args.Conversation;
string voicemailURI = String.Format("{0};opaque=app:voicemail",conv.SelfParticipant.Contact.Uri);
participants.Add(voicemailUri);
automation.BeginStartConversation(AutomationModalities.Audio, participants, null, StartConversationCallback, automation);
Related
I have another UWP question.
I'm trying to get all the UWP apps that I published on the MS Store, but it seems there is something wrong: I can only get the current one beeing executed, although I insert many store IDs, the ones from my apps, as suggested by MS Docs.
Here's the code (of course, in my code I insert the real IDs):
StoreContext context = StoreContext.GetDefault();
string[] productKinds = { "Application" };
List<String> filterList = new List<string>(productKinds);
string[] storeIds = { "firstID", "secondID", "thirdID" };
StoreProductQueryResult queryResult = await context.GetStoreProductsAsync(filterList, storeIds);
if (queryResult.ExtendedError == null)
{
foreach (var product in queryResult.Products)
{
// Do something with 'product'
}
}
Well, it only returns one item, the current one.
Is there a way to obtain even other store apps?
Am I doing something wrong?
Thanks a lot.
GetStoreProductsAsync is only for the products associated with the app (i.e. add-ons):
Gets Microsoft Store listing info for the specified products that are
associated with the current app.
[docs]
To solve the problem you might want to look in the direction of Microsoft Store collection API and purchase API (requires web app setup in Azure).
Other than that StoreContext class at its current state doesn't contain API to get product information about other apps and their add-ons.
I have added a custom environment variable and I'm unable to get it to return in the ExpandEnvironmentVariables.
These 2 calls work fine:
string s = Environment.GetEnvironmentVariable("TEST", EnvironmentVariableTarget.Machine);
// s = "D:\Temp2"
string path = Environment.ExpandEnvironmentVariables(#"%windir%\Temp1");
// path = "C:\Windows\Temp1"
However, this call returns the same input string:
var path = Environment.ExpandEnvironmentVariables(#"%TEST%\Temp1");
// path = "%TEST%\\Temp1"
I expect to get D:\Temp2\Temp1
What am I missing to correctly get the custom EnvironmentVariable in this last call?
Hans and Evk were correct in their comments. Since no one wanted to add an answer I'll close this question out.
For whatever reason ExpandEnvironmentVariables will not get any keys which were added after an application started. I also tested this with a running Windows Service. It was only after I restarted the service that new keys were found and populated.
This behavior is not documented in the Microsoft Documentation.
I have developped a uwp app that has a custom user control allowing handwriting recognition of the user input with a stylus into a textbox.
It works fine for common words, however my users often use technical terms and acronyms that are not always recognised or not recognised at all because they are not featured in the language I have set as the default recognizer for my InkRecognizer.
Here is how I set the default Inkrecognizer :
InkRecognizerContainer inkRecognizerContainer = new InkRecognizerContainer();
foreach (InkRecognizer reco in inkRecognizerContainer.GetRecognizers())
{
if (recognizerName == "Reconnaissance d'écriture Microsoft - Français")
{
inkRecognizerContainer.SetDefaultRecognizer(reco);
break;
}
}
And how I get my recognition results :
IReadOnlyList<InkRecognitionResult> recognitionResults = new List<InkRecognitionResult>();
recognitionResults = await inkRecognizerContainer.RecognizeAsync(myInkCanvas.InkPresenter.StrokeContainer, InkRecognitionTarget.All);
foreach (var r in recognitionResults)
{
string result = r.GetTextCandidates()[0];
myTextBox.Text += " "+result;
}
The expected results are generally not contained in the other textcandidates either.
I have read through the msdn documentation of Windows.UI.Input.Inking but haven't found anything useful on this particular topic.
Same goes for the Channel9 videos existing around handwriting recognition and the results that my google-fu have been able to conjure up.
Ideally, I'm looking for something similar to the WordList that existed in Windows.Inking
Is there a way to programatically add a wordlist to the pool of words of an Inkrecognizer or create a custom dictionary for handwriting recognition in a uwp app ?
and sorry for a poor title of the question
I´m trying to get all free rooms (not booked ones) from my exchange server. The thing is that I also get the rooms I have booked but nobody has accepted.
I would like to exclude them from the list after I book the room.
This is the code I use to book a room
ExchangeService service;
//...code to new-up and config service
var request = new Appointment(service)
{
Subject = booking.Subject,
Start = booking.Start,
End = booking.End,
Location = booking.Room
};
request.RequiredAttendees.Add(booking.Person);
request.RequiredAttendees.Add(booking.Room);
request.Save(SendInvitationsMode.SendOnlyToAll);
To note I have tried to call request.Accept() straight after Save() but without that "realy booking" the room. Pressing accept in Outlook is the only "fix". Needlessly to say I have tried everything I could find about this issue (I do not work with Exchange regularly).
And then the code to get free rooms
var rooms = service.GetRooms(locationAddress);
// all the meeting rooms at location
var rooms= rooms.Select(i => new AttendeeInfo { SmtpAddress = i.Address, AttendeeType = MeetingAttendeeType.Room });
// Get all availabilites from all rooms at given locations
var availability = service.GetUserAvailability(rooms, timeframe, AvailabilityData.FreeBusy);
foreach (var a in availability.AttendeesAvailability)
{
// Here we always get all the free rooms
// including the ones we booked earlier
// UNTIL somebody clicks accept in Outlook and then it does not appear here!?
}
I can´t see that the rooms are marked differently before they are accepted in Outlook so I can´t differentiate between them and pull out them ones I don´t want.
I also really think that those rooms should not be available so there must bee some enum/tick/mark I can put on the room before booking it but I totally missing it.
Edit
I realy don't understand why there is no option for AvailabilityData.Free in the enum in the GetUserAvailability method (only FreeBusy, FreeBusyAndSuggestions and Suggestions but no Free only!?)
Ok this is rather silly... the code (I inherited) did not include code to actually remove rooms that where taken (busy). I only just noticed this...
The code to fix this is simply this one
var busyRoomToRemove = a.CalendarEvents.ToList().Find(x => x.FreeBusyStatus == LegacyFreeBusyStatus.Busy);
a.CalendarEvents.Remove(busyRoomToRemove);
Sorry for the inconvenience :-)
I am working with the C# Event Log API in Windows (essentially everything in System.Diagnostics.Eventing.Reader).
I have an EventMetadata object and pull its Description property to retrieve the message template for an event.
Generally, these templates look similar to the following:
Network interface reports message %1
These variables are easily replaceable with actual data whenever I receive an event.
(EventLogRecord.Properties match up to the placeholders)
Here is where my problem comes in. The EventLogRecord.Properties sometimes contain different kinds of placeholders. These always begin in %% and I cannot find a way of resolving them.
As an example:
// This method is triggered when a new event comes in
async public static void ListenerEvent(object s, EventRecordWrittenEventArgs args) {
var evt = (EventLogRecord)args.EventRecord;
// This method retrieves the template from a ProviderMetadata object
// And replaces all %n with {n}
// So that we can string.Format on it
var tmp = TemplateCache.TemplateFor(evt);
// Need this since the indices start with 1, not 0
var props = new List<object> {string.Empty};
props.AddRange(evt.Properties.Select(prop => prop.Value));
// Now the message should be human-readable
var msg = string.Format(tmp, props);
}
Using the above example template, the Properties might be ["%%16411"] and now I end up with the following message
Network interface reports message %%16411
I figure my question now is, how do I replace this %%16411?
I have looked into ProviderMetadata and the rest of its properties but none seem to match up.
Any help figuring out how to resolve these placeholders (or even what they are/where they come from) is appreciated.
An event that shows this behaviour is 5152, as found here: http://community.spiceworks.com/windows_event/show/452-microsoft-windows-security-auditing-5152
Thank you.