Skip to main content

Posts

Outlook AdvanceSearch API not returning latest emails in the results

Using Office Interop AdvanceSearch API method to query a Outlook folder isn't returning all the results, it's only returning results from 2 days ago! This code been running fine for over 2 years why is it failing now, and only failing on one machine? Turnsout the it's a new machine after the last one died a couple of days ago, and this lead me to the answer - Indexes... The indexes hadn't finished re-building from the last retore point, and if you use API before the Indexes are built you might not get all the results. If you dig into the Indexing Options it even tells you this, shame the API can't surface this warning.
Recent posts

SqlDependency - getting the permissions working...

 After much banging my head against the internet here is a canonical example of how to configure SQL Server permissions, roles to get SqlDependency working in a .Net app. This is for sceneario where the identity running the .Net code is running as a configured user account with the db_datareader & db_datawriter. -- Create Schema User CREATE USER sql_dependency_schema_owner WITHOUT LOGIN; GO -- Create Schema for SqlDependency objects CREATE SCHEMA sql_dependency AUTHORIZATION sql_dependency_schema_owner; GO -- Create Role for users of [sql_dependency] CREATE ROLE sql_dependency_user; GO -- Grant role permissions GRANT CONTROL ON SCHEMA::sql_dependency TO sql_dependency_user; GRANT IMPERSONATE ON USER::sql_dependency_schema_owner TO sql_dependency_user; GRANT CREATE PROCEDURE TO sql_dependency_user; GRANT CREATE QUEUE TO sql_dependency_user; GRANT CREATE SERVICE TO sql_dependency_user; GRANT REFERENCES ON CONTRACT::[http://schemas.microsoft.com/SQL/Notifications/PostQueryNo...

Clean app startup (WPF)

Simple easy to read code is the building blocks for complex applications, and to this end, the is how I now start all desktop apps (written in XAML / WPF). This is nothing new (and not original) but it's been refined & destilled down to a point of simpliclity :) Single line written once and forgotten about... Need to add Exception handling - write it in a Module... Need to add Heartbeat monitoring - write it in a Module... Using DI - do it in a Module... Startup XAML - guess what, done in a Module... Want only one instance of the app - do it in a Module... So lifting from my updated Simple.Wpf.Template on gitHub , I have the following set of Modules defined - this forms the basis for all apps I'm asked to develop for clients: The complexity is hidden away in the ModuleLoader class, simple put this scans & loads any type with the ModuleConfigurationAttribute, orders the Modules according to the properties of the Attribute and dynamically invokes the Modules. Check out th...

Benchmarking DateTime.ToString("...")

Looking to eek-out as much perf as I can from some code (C#) at work, and looking at all the .ToString() manipulations in the code and I came across the following: How can I quickly workout if I want to do something around this? BenchmarkDotNet to the rescue, and this library really does make benchmarking easy (and fun!). I created an overload of the extension method which internally uses a cache to avoid the repeative ToString() calls: Only small issue was wanting to test a Static methods, and this only involved creating a wrapper class with annotated methods(calling the static implementations), also preloaded the internal cache: Results below, make-of-it what you will...

Rx EventAggregator<T> for desktop apps

In my continuing (point-less) mission to avoid using anything related to MS Prism - a quick implementation of an EventAggregator using Rx - took about 5 minutes to write for a problem I currently have, normally try and avoid using such a pattern as it can lead the scattering of business logic which can hard to 'follow' when refactoring / re-visting code. Trying to kepp the interace as simple and obvious as possible (symetric design) - this will be injected by the container: Simple base event class, not thing special at the moment, might add a timestamp in the future, but more likely to do that with Rx on the event stream using the apply named Timestamp method: Included a simplifed Schedulers wrapper - idea being you can get any of the Rx Schedulers in one place, and importantly makes unit testing easier: Show me the money...

Getting the last column to fit to available space in slickGrid

I wanted a quick diagnostics page in html / js and this included grid to show server logs, decided to use slickGrid . All pretty easy to use apart from one thing - last column to fill remaining space... Nothing in their examples, so here's one for posterity... Not sure if it's the preferred way, but it works - the most obivous issue for is doing a DOM search to get the Viewport element - this is tightly coupled to the current latest release. Stuck the implmentation in a Class and not provided any logic for creating Data, Columns or other grid optnios / plugins - tried to keep it simple...

Custom AuthorizationHandler for SignalR Hubs

How to implement IAuthorizationRequirement for SignalR in Asp.Net Core v5.0 Been battling this for a couple of days, and eventually ended up raising an issue on Asp.Net Core gitHub  to find the answer. Wanting to do some custom authorization on a SignalR Hub when the client makes a connection (Hub is created) and when an endpoint (Hub method) is called:  I was assuming I could use the same Policy for both class & method attributes, but it ain't so - not because you can't, because you need the signatures to be different. Method implementation has a resource type of HubInnovationContext: I assumed class implementation would have a resource type of HubConnectionContext - client connects etc... This isn't the case, it's infact of type DefaultHttpContext . For me I don't even need that, it can be removed completely  from the inheritence signature and override implementation. Only other thing to note, and this could be a biggy, is the ordering of the statements in th...