Outlook get FreeBusy information is slow - c#

My code is an MS Outlook addin and is used for creating a absence calendar for 60+ people of a team. The company uses MS Exchange.
I am retrieving their free/busy status with this code:
var namespace = ThisAddIn.thisOutlookApp?.GetNamespace( "MAPI" );
var recp = namespace.CreateRecipient( personName );
var freeBusy = recp.FreeBusy( startDate, MinPerChar: 60, CompleteFormat: true );
Although this works file, one call to FreeBusy() takes about 300 milliseconds. For 60 people and a time span of three months, this means my code takes nearly a minute.
I also tried this alternative:
recp.Resolve();
var exu = recp.AddressEntry.GetExchangeUser();
var freeBusy = exu.GetFReeBusy(...)
but no difference. The same code in VBA shows the same performance.
Is their a trick to speed up this call, or is there an alternative way to get the free/busy information, e.g. by accessing other people's calendar or by talking to the MS Exchange server itself?

Use GetUserAvailability EWS operation - it allows to request f/b info for multiple users in a single call.

I found a good solution myself:
I did not use the Outlook Interop API, but calls to the Exchange server itself using the EWS Managed API.
There is an excellent set of 101 sample projects. (It's really 101 samples!) and a very good step-by-step tutorial for getting started with the EWS Managed API.
"Exchange 2013 Get users' status setting programmatically" was the sample that I used.
However, I'm keen to hear about alternative solutions from SO users.

Related

Change Value in Firebase At Specific Time [duplicate]

I am looking for a way to schedule Cloud Functions for Firebase or in other words trigger them on a specific time.
Update 2019-04-18
There is now a very simple way to deploy scheduled code on Cloud Functions through Firebase.
You can either use a simple text syntax:
export scheduledFunctionPlainEnglish =
functions.pubsub.schedule('every 5 minutes').onRun((context) => {
console.log('This will be run every 5 minutes!');
})
Or the more flexible cron table format:
export scheduledFunctionCrontab =
functions.pubsub.schedule('5 11 * * *').onRun((context) => {
console.log('This will be run every day at 11:05 AM UTC!');
});
To learn more about this, see:
The Scheduling Cloud Functions for Firebase blog post introducing the feature.
The documentation on scheduled functions.
Note that your project needs to be on a Blaze plan for this to work, so I'm leaving the alternative options below for reference.
If you want to schedule a single invocation of a Cloud Function on a delay from within the execution of another trigger, you can use Cloud Tasks to set that up. Read this article for an extended example of how that can work.
Original answer below...
There is no built-in runat/cron type trigger yet.
For the moment, the best option is to use an external service to trigger a HTTP function periodically. See this sample in the functions-samples repo for more information. Or use the recently introduced Google Cloud Scheduler to trigger Cloud Functions through PubSub or HTTPS:
I also highly recommend reading this post on the Firebase blog: How to Schedule (Cron) Jobs with Cloud Functions for Firebase and this video: Timing Cloud Functions for Firebase using an HTTP Trigger and Cron.
That last link uses cron-job.org to trigger Cloud Functions, and works for projects that are on a free plan. Note that this allows anyone to call your function without authorization, so you may want to include some abuse protection mechanism in the code itself.
What you can do, is spin up an AppEngine instance that is triggered by cron job and emits to PubSub. I wrote a blog post specifically on that, you might want to take a look:
https://mhaligowski.github.io/blog/2017/05/25/scheduled-cloud-function-execution.html
It is important to first note that the default timezone your functions will execute on is America/Los_Angeles according to the documentation. You may find a list of timezones here if you'd like to trigger your function(s) on a different timezone.
NB!!: Here's a useful website to assist with cron table formats (I found it pretty useful)
Here's how you'd go about it:
(Assuming you'd like to use Africa/Johannesburg as your timezone)
export const executeFunction = functions.pubsub.schedule("10 23 * * *")
.timeZone('Africa/Johannesburg').onRun(() => {
console.log("successfully executed at 23:10 Johannesburg Time!!");
});
Otherwise if you'd rather stick to the default:
export const executeFunction = functions.pubsub.schedule("10 23 * * *")
.onRun(() => {
console.log("successfully executed at 23:10 Los Angeles Time!!");
});

How to find the status of an Azure v2 VM via rest / powershell ARM

I have just converted some existing VMs to v2 (Resource Manager) VMs, and subsequently updating scripts etc.
I have this line to find out the status (stopped / running / starting) of machines.
string URL = string.Format("https://management.azure.com/subscriptions/{0}/resourceGroups/{1}/providers/Microsoft.Compute/virtualmachines/{2}?api-version=2015-05-01-preview",
SubscriptionID,
ResourceGroup,
ComputerName
);
In the classiccompute model I would get some json that I could parse to find status. Now however all I get is json object describing my machine. (size, attached disks etc)
No problem I thought! there's going to be an earlier version of the API that gives what I'm looking for I found a versioning document that talks about the service management versions but I can't find anything about the ARM versioning.
No problem I thought, I'll see what Powershell does. Alas it seems to read the same API, and give the same information. (and obviously service management mode no longer sees my VM)
From what I've seen in the last hour of poking around this, there's no way of checking the status of a v2 VM. I imagine I'm missing something that is getting lost in the sea of V1 google results.
How do I find out if my v2 VM is running? (bonus points for a document that covers the ARM api versions!)
After some further digging around! it appears the answer is to append /instanceview to the URI which will give the state of all of the attached resources.
For powershell there is the -status parameter for Get-AzureVM which will give the same json resource.

Why is it so difficult to find the printer status in windows?

Using C# - I'm trying to find a list of all printers that are local and online (i.e. connected and ready to accept print requests)
I know the printer driver works - jobs will just wait until the printer is back online, but I need to find those specific that are online. These are clearly available to windows but the .net framework doesn't seem to accurately expose those which are currently online.
I'm trying to use lots of different methods and none seem to accurately work
// Get a list of available printers.
var printServer = new PrintServer();
var printQueues = printServer.GetPrintQueues(new[] { EnumeratedPrintQueueTypes.Local, EnumeratedPrintQueueTypes.Connections });
foreach (PrintQueue printQueue in printQueues)
{
Console.WriteLine(printQueue.IsOffline); // This works for IsOffline, but doesn't tell us those that are online - and it's not an inverse relationship
}
very frustrating - any help appreciated.
Should add I'm using windows 8.1, and the solution should work also with win 7+
Edit:
So given the following collection of printers :
I would expect to see something along the lines of
Getting all Printers
Send To OneNote 2013 : Online
Pack1 : Offine
Microsoft XPS Document Writer : Online
Fax : Online
EPSONB12B28 (XP-412 413 415 Series) : Offine
Brother MFC-9970CDW Printer : Online
But they are ALWAYS reported as Online on any status I see
I have queried just about every conceivable windows device either by native driver or using Windows Management Instrumentation (WMI) classes.
To get you started, take a read of this article with C# source: http://www.codeproject.com/Articles/80680/Managing-Printers-Programatically-using-C-and-WMI
Also, not in C# but VB, some quick glance info on the same subject here: http://msdn.microsoft.com/en-us/library/aa394598(v=vs.85).aspx
Full WMI reference here: http://msdn.microsoft.com/en-us/library/aa394572(v=VS.85).aspx
Cheers and good luck!

Get Biztalk's message count through C# .NET

How can I get total message sent / received at any given point of time by the BizTalk Server through C# .NET?
Any Ideas to achieve this?
Message tracking in BizTalk is done using BAM. Of course, you could write your own database and data access API, but why would you?!? See Using Business Activity Monitoring for a primer. Don't be put off by the learning curve - once you get over it, you'll love it!
This book has a very good section on BAM, don't be put off by the version - the basic concepts still apply to 2010.
And finally this tool will speed up your development.
A simple approach would be to use the existing BizTalk Perfmon Counters to monitor messages (albeit since the last Host instance restart)
Assuming that you've got a BizTalk Server called BizTalkServer with a SendHost and ReceiveHost configured, the below message counters should give an indication of the messages sent / received:
PerformanceCounter msgsReceivedCounter = new
PerformanceCounter("BizTalk:Messaging", "Documents received", "ReceiveHost", "BizTalkServer");
msgsReceivedCounter.ReadOnly = true;
PerformanceCounter msgsSentCounter = new
PerformanceCounter("BizTalk:Messaging", "Documents processed", "SendHost", "BizTalkServer");
msgsSentCounter.ReadOnly = true;
lblSent.Text = string.Format("{0}", msgsSentCounter.NextValue());
lblReceived.Text = string.Format("{0}", msgsReceivedCounter.NextValue());
Note that if you have more than one BizTalk host in your group, you will need to aggregate across all hosts.
More on using the PerformanceCounter class in C# here.
More on the BizTalk PerfMon Counters here.
You can get that information from querying Tracking Database MessageInOutEvents table. This is one single table where all the activities are stored.
The only requirements is you should have switched off the global tracking property in your BizTalk environment.

Limiting records synchronized to mobile device

Similar questions have been asked before but after a day of going through the answers I'm still very confused.
I'm using Microsoft's Sync Framework with SQL2008 on the server and SQL CE on Windows Mobile devices. I would have thought this was a VERY common requirement. I don't want to replicate large tables onto the mobile device. I only want the records that are needed. For example, each user will need their "jobs" out of the jobs table. They don't need any other user's jobs. So I need something like "where jobId = 3" for one device and "where jobId=4" for another etc.
This looked promising: http://jtabadero.spaces.live.com/blog/cns!BF49A449953D0591!1203.entry
but unfortunately it doesn't work with my code. This code from the sample seems to be trying to get the code that contains the SQL:
var remoteProvider = (LocalDataCache1ServerSyncProvider)syncAgent.RemoteProvider;
var selectIncrementalInsertsCommand = remoteProvider.SalesLT_CustomerSyncAdapter.SelectIncrementalInsertsCommand;
BUT the code containing the SQL (generated by VS) is on the server-side and only a proxy is available in the client-side code. This is how the proxy is added:
// The WCF Service
var webSvcProxy = new MicronetCacheSyncService();
// The Remote Server Provider Proxy
var serverProvider = new ServerSyncProviderProxy(webSvcProxy);
// The Sync Agent
var syncAgent = new MicronetCacheSyncAgent();
syncAgent.RemoteProvider = serverProvider;
So how can I get to the server-side code that contains the sql from the client-side? Sorry I'm not explaining this very well but I guess it's unlikely anyone will have an answer. The short version is does anyone know a SIMPLE way to limit the records that are synced to a mobile device is this type of app? I think the example was meant for desktop apps.
It looks to me like this sync framework is another one of Microsoft's half-baked releases that is really just a beta. It's starting to remind me of some previous horrible experiences with Entity Framework 1.0 :(
The tutorial at http://msdn.microsoft.com/en-us/library/dd918848%28SQL.105%29.aspx contains everything you need to provision filtering for a scope.
FYI, that tutorial is for Sync Framework 2.0, whereas from your code above it appears you're using Sync Framework 1.0 -- a legacy product.

Categories

Resources