Recent

Author Topic: TvPlanIt fixes  (Read 38512 times)

wp

  • Hero Member
  • *****
  • Posts: 13512
TvPlanIt fixes
« on: June 07, 2016, 09:56:25 pm »
This is a continuation of the thread forum.lazarus.freepascal.org/index.php/topic,32871.msg212138.html and covers the discussions for fixing the TvPlanit components in lazarus-ccr.

@magu: Now I put your changes into the ccr version of TvPlanit. I removed your changes related to lrs resources because I think res should do as well and I think this would simplify maintaining Delphi compatibility (although this is not my goal). Now I am able to start your demo program, but I soon run into crashes. Could you compare with your version? Maybe I forgot something important?

I also played with the original TvPlanit from sourceforge in Delphi 7. What is doing relatively fine is the BDEDatastore, but the FlexDataStore has issues as well.

I am still unclear how to begin fixing the component...

magu

  • New Member
  • *
  • Posts: 37
Re: TvPlanIt fixes
« Reply #1 on: June 07, 2016, 11:10:06 pm »
Hey, thanks for this.

Not sure what you want me to do [my day (and night) job involve 0% programming] however the list of bugs I have encountered are the following:

a) on exiting (if the debugger is running) and a resource is loaded: SIGSEGV (NB this error is actually trapped in the component itself).
b) Week viewer : if you click on an event, the viewer will allow you to edit the text: this leads to an access violation *whether you edit the text or not*
c) Task List: If you try ticking the task there as done:  SQLRes: Field not Found "Record ID"
d) If you select Add Task: Access Violation
e) I had also encountered some bugs with the contacts component (basically it wasn't showing any contact).
f) with regards to the contacts component the add contacts doesn't get summoned...

Personally I'm beginning to think it may make more sense to remove the database code from the components and turn them into something like Treeview: ie. the developer is in charge of extracting data into a tlist and the components will only be responsible for displaying the data from the list: this would also have the advantage of making the components more universal.

I will try doing some more work on this over the next weekend.




wp

  • Hero Member
  • *****
  • Posts: 13512
Re: TvPlanIt fixes
« Reply #2 on: June 08, 2016, 12:59:33 am »
Yes, just showing your list of bugs is fine. I see that my adaption of your patches is correct.

In the meantime, I was able to removex the SIGSEGV when the program ends. The way TurboPower had accessed TList items really demonstrates that the TvPlanIt components were written in the old days of Delphi 4.

One thing I wonder when running your demo: How can I store the resource that is created in the first step? With every program start I have to repeat this.

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1877
Re: TvPlanIt fixes
« Reply #3 on: June 08, 2016, 06:36:22 am »
You could also have a look here:

https://github.com/tcs-ulli/tvplanit

Here, tvplanit is in active use, inside PrometErp.

xinyiman

  • Hero Member
  • *****
  • Posts: 2261
    • Lazarus and Free Pascal italian community
Re: TvPlanIt fixes
« Reply #4 on: June 08, 2016, 09:02:37 am »
Hello Don Alfredo, I installed the package that you reported you, you know where to find an example to prove how it works?
Win10, Ubuntu and Mac
Lazarus: 2.1.0
FPC: 3.3.1

wp

  • Hero Member
  • *****
  • Posts: 13512
Re: TvPlanIt fixes
« Reply #5 on: June 08, 2016, 10:14:58 am »
Except for a few modifications this package is close to the ccr version, but back by a few months. For example, it does not compile under fpc 3.1.1 which the ccr version does. And it does not publish any datastore which is the key to using the planner. DonAlfredo, are you sure that this package is really compiled into PrometErp?

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1877
Re: TvPlanIt fixes
« Reply #6 on: June 08, 2016, 12:33:58 pm »
@wp.
No, I am not sure !
My last look into it was a year ago, so my knowledge is outdated.
Just wanted to present another source that might have been helpfull in getting things running again !

wp

  • Hero Member
  • *****
  • Posts: 13512
Re: TvPlanIt fixes
« Reply #7 on: June 08, 2016, 03:05:10 pm »
Thanks for letting me know.

magu

  • New Member
  • *
  • Posts: 37
Re: TvPlanIt fixes
« Reply #8 on: June 08, 2016, 11:02:45 pm »
@wp.

I managed to get a default resource to load at runtime. You need to add the following lines to TForm1.FormCreate, as per the following

Code: Pascal  [Select][+][-]
  1. procedure TForm1.FormCreate(Sender: TObject);
  2. begin
  3.   VpFlexDataStore1.Load;
  4.   VpFlexDataStore1.ResourceID := 1;
  5. end;
  6.  

In reality its not very intuitive, the same result can be achieved by using Vpresourcecombo1.DataStore.(load/resourceID) and Vpcontrollink1.Datastore.(load/resourceID)

wp

  • Hero Member
  • *****
  • Posts: 13512
Re: TvPlanIt fixes
« Reply #9 on: June 09, 2016, 12:43:10 am »
Thanks, good observation which helps a lot.

Today I activated the field mapper which opens after selecting "Map database fields" in the context menu of the FlexDatastore. It took me some time to realize that the database must be entered with full path in the SQLite3Connection for this to work.

The next task will be to find out why the entered data are not stored in the database. Starting with a new empty database (only fields created) the creation of the first resource fails with a "Field ResourceID not found" error -- this is because the new resource is not written to the db.

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1877
Re: TvPlanIt fixes
« Reply #10 on: June 09, 2016, 08:39:54 am »
I have worked with TvPlanit in the past.
And made a working implementation with using mORMot as a database backend.
This makes it possible to use all kinds of databases, supported by mORMot and Zeos.
Just had a look at it again. Still working a bit !
If there is any interest, I am willing to share code.

magu

  • New Member
  • *
  • Posts: 37
Re: TvPlanIt fixes
« Reply #11 on: June 09, 2016, 08:47:52 am »
@wp

If you will be checking the map database fields you may notice that in my original example in the case of tasks and contacts the resourceid and recordid were switched.
However after correcting these there still are problems with contacts and tasks.
I have looked into tasks and I believe the issue when updating a task may be that the wrong fields are being updated.
Haven't had time to look into this properly, but my observations to vpflxds.pas were the following:

1) the post actions (which should update the database) are different.
eg. compare
procedure TVpFlexDataStore.PostEvents;
with
procedure TVpFlexDataStore.PostTasks;

PostEvents has the following code

Code: Pascal  [Select][+][-]
  1. ...
  2.   {if no events dataset has been defined then bail.}
  3.   if (FEventsDataSrc = nil)
  4.   or (FEventsDataSrc.DataSet = nil) then
  5.     Exit;
  6.  
  7.   if (Resource <> nil) and Resource.EventsDirty then begin
  8.     { Dump this resource's dirty events to the DB }
  9.     if (FResourceDataSrc <> nil)
  10.     and (FResourceDataSrc.DataSet <> nil) then begin
  11.  
  12.       FResourceDataSrc.DataSet.Open;
  13.  
  14.       FN := GetFieldName(FEventMappings, 'ResourceID');
  15.       if (FN <> '')
  16.       and FResourceDataSrc.DataSet.Locate(FN, Resource.ResourceID, [])
  17.       then begin
  18. ...
  19.  

PostTasks

Code: Pascal  [Select][+][-]
  1. ...
  2. if (Resource <> nil) and Resource.TasksDirty then begin
  3.  
  4.     if (FResourceDataSrc <> nil)
  5.     and (FResourceDataSrc.Dataset <> nil) then begin
  6.       FResourceDataSrc.DataSet.Open;
  7.       if FResourceDataSrc.DataSet.Active then begin
  8.                 FN := GetFieldName(FTaskMappings, 'ResourceID');
  9.         { Dump this resource's dirty contacts to the DB }
  10.         if not FResourceDataSrc.DataSet.Locate(FN, Resource.ResourceID, [])
  11.         then Exit;
  12.       end; {if FResourceDataSrc.DataSet.Active}
  13.     end; {if (FResourceDataSrc ...}
  14.  
  15.     {filter tasks}
  16. ...
  17.  

The different code is meant to do the same purpose, however note that for tasks the procedure doesn't trap for a failure to link a 'ResourceID' unlike PostEvents (all it needed was a (FN <> '').

My other issue with this code is whether
FN := GetFieldName(FTaskMappings, 'ResourceID');
FResourceDataSrc.DataSet.Locate(FN, Resource.ResourceID, [])

Are correct:

They are looking for the [ResourceID] as found in the ResourceTable but with the name used in the TasksTable.
I am not sure whether this should be:
        FN := GetFieldName(FResourceMappings, 'ResourceID');
OR
whether you first want to locate the ResourceID in the tasksTable, verify that it exists in the ResourceTable table and then proceed....

JD

  • Hero Member
  • *****
  • Posts: 1913
Re: TvPlanIt fixes
« Reply #12 on: June 09, 2016, 02:17:03 pm »
I have worked with TvPlanit in the past.
And made a working implementation with using mORMot as a database backend.
This makes it possible to use all kinds of databases, supported by mORMot and Zeos.
Just had a look at it again. Still working a bit !
If there is any interest, I am willing to share code.

Talk about timing. I was just about to post a question concerning this. I have a PostgreSQL database backend & I'm trying to use TvPlanit to save scheduling information into it by passing JSON strings. I'll greatly appreciate seeing how you managed to implement CRUD operations with TvPlanit in your application.

JD
« Last Edit: June 09, 2016, 02:40:24 pm by JD »
Linux Mint - Lazarus 4.6/FPC 3.2.2,
Windows - Lazarus 4.6/FPC 3.2.2

mORMot 2, PostgreSQL & MariaDB.

DonAlfredo

  • Hero Member
  • *****
  • Posts: 1877
Re: TvPlanIt fixes
« Reply #13 on: June 09, 2016, 02:47:55 pm »
@JD
Allright. I will dive into it again.
The trick for this: a controller that translates all DataSet commands into CRUD for mORMot (REST/JSON).
Write once, use everywhere. I will report back.

JD

  • Hero Member
  • *****
  • Posts: 1913
Re: TvPlanIt fixes
« Reply #14 on: June 09, 2016, 02:58:34 pm »
@JD
Allright. I will dive into it again.
The trick for this: a controller that translates all DataSet commands into CRUD for mORMot (REST/JSON).
Write once, use everywhere. I will report back.

Thanks a million. I'll be waiting.....

JD
Linux Mint - Lazarus 4.6/FPC 3.2.2,
Windows - Lazarus 4.6/FPC 3.2.2

mORMot 2, PostgreSQL & MariaDB.

 

TinyPortal © 2005-2018