Please forgive me if I've made some noob mistakes - I'm relatively new to C#. I've had trouble getting nuget packages to play ball and have had to do all sorts of strange things to get DLLs visible for this example. Initially I tried using the latest versions of all packages but following some discussions on various forums I tried to downgrade some of them (EntityFrameworkCore). Any assistance in this would be greatly appreciated!
- It should be possible to use the EntityFramework to create a SQL database if it does not exist, and to interact with said database.
- Receiving the error
Microsoft.Data.SqlClient is not supported on this platform
- I am running Windows 11 and ManicTime is written using .NET.
PS> dotnet --info
.NET SDK:
Version: 7.0.203
Commit: 5b005c19f5
Runtime Environment:
OS Name: Windows
OS Version: 10.0.22621
OS Platform: Windows
RID: win10-x64
Base Path: C:\Program Files\dotnet\sdk\7.0.203\
Host:
Version: 7.0.5
Architecture: x64
Commit: 8042d61b17
.NET SDKs installed:
6.0.408 [C:\Program Files\dotnet\sdk]
7.0.203 [C:\Program Files\dotnet\sdk]
.NET runtimes installed:
Microsoft.AspNetCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.AspNetCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.AspNetCore.App]
Microsoft.NETCore.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.NETCore.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.NETCore.App]
Microsoft.WindowsDesktop.App 6.0.15 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 6.0.16 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
Microsoft.WindowsDesktop.App 7.0.5 [C:\Program Files\dotnet\shared\Microsoft.WindowsDesktop.App]
-
Clone this repo and open the solution in Visual Studio.
-
Install ManicTime Free version (https://www.manictime.com/download/).
-
Ensure that your preferred local MS SQL Server instance is installed and running.
-
Open this solution and update the connection string in
TagPlugin.Data.Context
to reflect a valid connection string to your database with rights to allow for DDL statement execution. -
Open a File Explorer and navigate to
%APPDATA%\..\Local\Finkit\ManicTime\Plugins
- this is where the build must be copied to so that the ManicTimeClient.exe can read it. -
Ensure that the appropriate nuget packages have been installed on your system, namely:
microsoft.data.sqlclient\5.1.1 microsoft.entityframeworkcore\6.0.16 microsoft.entityframeworkcore.abstractions\6.0.16 microsoft.entityframeworkcore.relational\6.0.16 microsoft.entityframeworkcore.sqlserver\6.0.16 microsoft.extensions.caching.abstractions\6.0.0 microsoft.extensions.caching.memory\6.0.1
I also installed the latest version of EntityFrameworkCore, but this configuration is the one that replicates my current state.
-
Update the relative paths for the required assemblies (sorry!) in:
TagPlugin.Data.csproj
forMicrosoft.EntityFrameworkCore
andMicrosoft.EntityFrameworkCore.SqlServer
TagPlugin.Example.csproj
forMicrosoft.Data.SqlClient
,Microsoft.EntityFrameworkCore
,Microsoft.EntityFrameworkCore.Abstractions
,Microsoft.EntityFrameworkCore.Relational
,Microsoft.EntityFrameworkCore.SqlServer
,Microsoft.Extensions.Caching.Abstractions
, andMicrosoft.Extensions.Caching.Memory
-
In the Post Build Events - Visual Studio should copy the resulting plugin build to the appropriate directory.
-
Close and restart ManicTime (it needs to be closed from the taskbar and may be a hidden icon).
-
In the options menu at the top-right of the ManicTime screen, the plugins can be accessed, find and activate this sample plugin.
-
The
Send tags
command probably won't produce any output, but if it's working correctly it should create a text file and inform you of this with a MsgBox popup. -
Try to create the database.
-
Open the application log of ManicTime, found in
%APPDATA%\..\Local\Finkit\ManicTime\Logs
and check most recent entries for any errors. If there are none, open SSMS and check whether the database was created. -
Please please PLEASE let me know if it worked for you.
An example of how to create custom ManicTime client plugins. ManicTime client supports three different types of plugins:
- Tag source plugin
- Timeline plugin
- Tracker plugin
Within ManicTime a tag plugin can be used to:
- Get tags to ManicTime from an outside service
- Export created tag activities (tags with start and end time) to an outside service
There are two important files: ImportTags/TagsImporter.cs Here you can get your tags from any service and pass them to ManicTime as a collection of TagSourceItem objects.
ExportTags/TagsExporter.cs This will return a collection of TagActivity objects which you can then export to other services.
- Compile the project (source/tag-plugin).
- After you compile it, there should be a folder in repository root - installable-plugin/< BuildConfiguration >
- Go to ManicTime, Settings -> Advanced -> Open db folder
- Copy folder installable-plugin/< BuildConfiguration >/Plugin to database folder, so that in the database folder it looks like ....\db folder\Plugins\Packages\ManicTime.TagSource.SampleTagPlugin...
- Run ManicTime
If you go to Plugins, you should now see a new plugin
Click on Settings, to add new connection
Then go to Add tag, you should see some new tags
Make some tags, then export them
Client plugins (Tag plugin and Timeline plugin) can be difficult to troubleshoot or simply irritating to test manually.
One thing you can do, is attach debugger to ManicTimeClient.exe process.
To do this:
- Switch to Debug build.
- Open plugin project properties.
- Under Build property, "Output" section: edit "Output path:" relative to ManicTime's database folder. e.g. [ManicTime Database folder]\Plugins\Packages\ < PackageName >\Lib\
- Under Debug property, "Start action" section: pick "Start external program:" and set it to ManicTimeClient.exe executable (ManicTime.exe in case of TrackerPlugin). e.g. C:\Program Files (x86)\ManicTime\ManicTimeClient.exe
- Make sure ManicTime Client settings option "Settings -> General -> Keep user interface running when main window closes" is unchecked.
- Make sure ManicTime Client is not running.
- Press Start (F5) to start debugging
Starting project in Debug mode should open instance of ManicTime Client with debugger attached. Any breakpoints set in project should now be hit as the plugin code executes.