DESKTOP EDITION CLOUD EDITION SERVER EDITION GUIDES FORUM

Does it have an API?


#18

I am also eagerly waiting for this feature. Any rough eta?


#19

I would like to integrate Manager into my existing systems in order to generate invoices and send them out… etc. This would make Manager useful to SAAS apps.

This would save so much time from rolling your own invoicing system.


#20

Would love to see how it is progressing! Great feature


#21

I’m making some progress. There is now Manager.dll .NET library which is low-level reader/writer for .manager files. In other words, it is now possible to create/read/write .manager files programatically.

The problem is that this library requires local and exclusive access to the file which would be somewhat limiting. For example, you could make a program that could bulk-delete or bulk-create something in Manager but that’s probably it.

I’m working on remote API which would allow remote access to Manager instance.


#22

I tried it out - but could use some pointers.

How do I add a deserialize a simple object? or add another? Not expecting a full documentation;

this is how far I got:

PersistentDictionary pd = new PersistentDictionary(file);
Type[] types = Serialization.GetTypes(); //goes ok
try
{
    foreach (Guid guid in pd.Keys)
    {
        Type type = Serialization.GetTypeByGuid(guid); //goes fine - gives 'Schema' as first key/object
        byte[] bytes = pd.Get(guid); //gives me 18 bytes
        Guid guidType = Serialization.GetGuidByType(type);
        var e = Serialization.Deserialize(guidType, bytes); //throws Proto exception                        
        var d = Serialization.Deserialize(type.GUID, bytes); //throws ManagerException - no message
    }
}
catch (Manager.SerializationException sex)
{
    Debug.WriteLine(sex.Message);
}

#23

Check the latest version (14.12.51). I’ve added new class PersistentObjects to Manager.dll which is basically a wrapper around PersistentDictionary and will allow you to read/write objects from .manager files far easier.

See example:

using System;
using System.Linq;
using Manager;
using Manager.Model;

namespace Test
{
    class Program
    {
        static void Main()
        {
            // Open or create a file
            var objects = new PersistentObjects("test.manager");

            if (!objects.Values.OfType<Customer>().Any())
            {
                // Create some customers
                objects.Put(new Customer() { Key = Guid.NewGuid(), Name = "C1" });
                objects.Put(new Customer() { Key = Guid.NewGuid(), Name = "C2" });
                objects.Put(new Customer() { Key = Guid.NewGuid(), Name = "C3" });
            }

            if (!objects.Values.OfType<Supplier>().Any())
            {
                // Create some suppliers
                objects.Put(new Supplier() { Key = Guid.NewGuid(), Name = "S1" });
                objects.Put(new Supplier() { Key = Guid.NewGuid(), Name = "S2" });
                objects.Put(new Supplier() { Key = Guid.NewGuid(), Name = "S3" });
            }

            // Enumerate customers
            foreach (var e in objects.Values.OfType<Customer>())
            {
                Console.WriteLine(e.Name);
            }

            // Enumerate suppliers
            foreach (var e in objects.Values.OfType<Supplier>())
            {
                Console.WriteLine(e.Name);
            }

            Console.ReadLine();
        }
    }
}

#24

If I run my own tools. Is there a structure checker for the objects if anything is misplaced or deleted when it shouldn’t be?

Here’s my tool to convert receipts/payments into transfers, supports foreign currencies. Maybe someone else may find it useful too, there’s pre compiled programs in the releases tab.


#25

The software is forgiving when it comes to data structure. If some data is missing or is incorrect, the software should be able to handle that. If it doesn’t, then I consider that a bug and it will get fixed. So don’t worry about structure checker. Any structure and any data is valid.


#26

So can you provide some basic information on how to use the API?


#27

@WindowDynamics, the example I’ve posted above is fully functional program that is interacting with API. Full documentation will be eventually available, for the time being, it’s probably best if you mention what problem are you trying to solve with API and I’ll give you necessary pointers.

The main limitation of current API is that PersistentObjects class requires exclusive access to .manager file which restricts what you can do with API. I’m planning to add one more API which will allow to access data live and remotely.


#28

OK Thank You. What I want to do is write a google apps script that automatically creates an invoice in Manage when a job is marked as completed on google calendar.

I’m not sure if that is possible yet. I would need to look up customers by email address then create a new invoice based and information embedded in my calendar.

Thank You


#29

It would be possible but the script wouldn’t be able to write into your .manager file if it’s open by Manager itself.

Are you familiar with C# or do you use different programming language?


#30

So it would only work if manager is closed? Mostly I’t something I want to work in the background anyway, maybe on a time trigger once a day. I’m not familiar with C# but I am with C++, java script, java, python so I though I could figure it out with some examples and hints. I was looking at installing mono.


#31

I tried using the sample provided by lubos, it compiles, but when I try and run it I get an error box:

An unhandled exception of type 'System.TypeLoadException' occurred in mscorlib.dll

Additional information: Could not load type 'Manager.PersistentObjects' from assembly 'Manager, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null'.

I have tried forcing my project settings to x86 and x64 but this hasn’t helped. I am using Visual Studio 2012, I have created an empty console project, pasted the code from lubos into Test.cs and added Manager.dll (latest version) as a reference, and also as a build link (so it is copied into the build directory).

Any tips?


#32

Ahh, found this link:

What could be causing a System.TypeLoadException in a Visual Studio Unit Test?

Specifically:

I just banged my head against this one for an hour. The problem was that I had a command line project named Something.exe, which was using a class library project named Something.dll.

This was my exact issue, I had created my C# project and called it ‘Manager’ and that project referenced Manager.dll and it seems if the project name and dll name are the same things do not work correctly. I have renamed my project and now it is working (just had to grab the protobuf-net reference).


#33

Can’t find Manager.PersistentObjects in the latest version.


Manager.dll
#34

I have 3 major migrains when I read this.

  1. RESTful API sounds such a good idea. Its in fact horible.
  2. I really need a C/C++ Library
  3. Data recovery of .manager files/possible matching library.

RESTful API to stay third party compadible end up with multi layers of versioning where you have to maintain broken features to keep legacy compadiblity in something that is exposed to the network or have third parties complain every time you break the RESTful API. I really don’t like this.

C/C++ Library under Linux I can use PHP, Python, Perl, Java .net … Fairly much any language I want. Advantage even if C/C++ library is talking RESTful if something is broken you network side you can fix by removing the broken feature network side as long as the C/C++ interface to applications does not change. Please note supporting all those different languages is important for intergrating SugerCRM, odoo… I am heavily a Linux user and more open source ERP and CRM are normally run on Linux. I am fairly sure a C/C++ library can be used the same kinds of ways under OS X and Windows.

Versioned in a C/C++ library is many times safer than versioned over a network interface. Accessing .net runtimes from PHP, Python Perl… is painful.

So far I have not seen a single thing documenting how data is stored in the .manager file. If a document of the manager file existed I would be tempted to write a C/C++ library for accessing it. This would allow other programs to add a import/export to and from the .manager file.

From my point of view we need up to 2 C/C++ and 1 .net libraries with stable APIs.
1 Plugin for desktop/server/cloud this being .net. Note being a plugin includes the means to provide output. So output for server and desktop uses that the extention looks part of the program.
2 Network communication to talk over network to the Server/Cloud edition this being C/C++
3 Library to read/write .manager files this also being C/C++

The last 2 are C/C++ because these have to have the broadest langauge support… Applications are unlikely to be wanting over network and read write .manager files directly at the same time.

Your current Embedded edition plan will not work for gnucash, kmymoney, odoo, sugercrm… basically language barrer and requiring .net runtime when otherwise they would not require it.


#35

I agree a C interface would be great. Perhaps we can use mono to compile the embedded edition to be cross platform.

Would the embedded edition need to be thread safe since multiple clients might be accessing it?


#36

I disagree with oiaohm. A RESTful API is by far the most robust and compatible way to go, and because manager pretty much already is URL-based, its a relatively easy path. Yes, REST can be implemented poorly, but so can any other technology. Merley stating that REST is horrible doesnt make any sense and is just a statement without evidence…

But from a personal point of view I will not need any API.


#37

i have tried but failed.

it seems some data was missing.