Hi !
I've got 2 table : 1: Measurement 2: Puffer.
I XAF, when I fill datas in detailview of measurement, I will save the data.
So here are my problems :
I use Measurement Onsaving method.
In first time I would like to save data to Puffer, and NO SAVE into Measurement,- second time I get back the data from Puffer, save to the Measurement, then delete from the Puffer.
- How can I prevent in Measurement Onsaving method the save the actual datas into the table ? (I would like to no save !!!).
- How can I save data In Measurement Onsaving method to save datas into Puffer ?
I think something lik this, but I know, this code is not correct :
Measurement Onsaving method()
{
var firstmeasurement = new PUFFER(Session);
firstmeasurement.kg = 35;
firstmeasurement.save();
//Disable save into measurement table ??
// base.OnSaving();
}
Any explanation :
I have a scale. Every record in Measurement table includes 2 measurements,
e.g. Measrement 1: 20 kilogramm, Measurement 2 : 5400 kilogramm.
After, the first measurement I save the data to the temporary table, after the second measurement I delete the data from the Puffer table, I create an ID for this measurement, and I save it into Measurement table.
Thanks for the help,
Zoltan
Hi Zoltan.
Your scenario looks rather unusual; possibly you are trying to implement some UI interaction by manipulating persistent object in an inappropriate manner. If you do not want to save the Measurement object, it makes no sense to create it. Would you please describe your final task in greater detail? I believe we can find an exact solution.
Hi Zoltan.
Please accept my apologies for the delayed response.
Thank you for the explanation. If I understand your requirements correctly, the PUFFER table is useless. I suppose it contains fields similar to the MEASUREMENT table. I believe it will be simpler to use a single MEASUREMENT table (as it contains all the required fields) and add a boolean field to denote an unfinished measurement from the final. This would also allow you to filter the list view by this flag to find partial and complete measurements.
Hi Michael !
I think, my explanation was unsual, but I think, it was the way to understand me. Sorry for the big pics.
I has think about your suggestion too, but I got the next problem with it :
Every measurement has a unique serial number. If I have an unfinished measurement, it has not got a serial numer, that's why I cannot save.(I have more than one 1st measure. I has got unique key for serial number.) To generate the serial number after th 1st measurement is not option, it will got after the 2nd measurement.
Bonus : It will be interesting for me, to tilt the save when leaving the detailview. (Tilt in the onsaving method, or tilt in …)
thanks for the help,
Zoltan
Hi Zoltan.
Are you experiencing the mentioned performance issue in the real application? If so, you can use Server Mode for such list views.
As for serial numbers, you can generate them after the second measurement is done and the "finished" flag is set, while keeping unfinished measurement records without this number. I suppose you are not using this serial number as a primary key property. We consider it is a bad practice to add meaning to key fields and always recommend to use surrogate keys.
>>>It will be interesting for me, to tilt the save when leaving the detailview.
I am afraid the eXpressApp Framework design does not provide means to support this behavior.
Hi Michael !
"Are you experiencing the mentioned performance issue in the real application? If so, you can use Server Mode for such list views."
No, I have not any experience, that"s why asked the question, what is the best way to implement it.
In the application designer,- Model.DesgignedDiffs.xafml I set up the UserServ ermode to true.
"As for serial numbers, you can generate them after the second measurement is done and the "finished" flag is set, while keeping unfinished measurement records without this number. I suppose you are not using this serial number as a primary key property. We consider it is a bad practice to add meaning to key fields and always recommend to use surrogate keys."
Yes, of course, I don't use serial number as a primary key,- I use XpObject - Oid field,- but I would like to use unique index for this serial number, to protect the database itself.
>>>It will be interesting for me, to tilt the save when leaving the detailview.
I am afraid the eXpressApp Framework design does not provide means to support this behavior.
O.K. It seems, the only way to accomplish my task, use the solution, that you recommended.
No PUFFER table, only MEASUREMENT table with the bool field.
So, is it right ?
Hi Zoltan.
Your understanding is correct. As for the unique index of the serial number column, you can allocate a range of "invalid" serial numbers for unfinished measurements, for example. Should you need any further assistance, please let me know.
Hi Michael !
I tried to realize your suggestion, but I got a new problem.
"As for serial numbers, you can generate them after the second measurement is done and the "finished" flag is set, while keeping unfinished measurement records without this number. "
THe problem is the next :
In 1st measure I set the datas, do the measure save. O.K.
I do the 2nd measure.
User press NEW button.(New button, because it is a new measurement). He fill the registration plate number field, I search this unfinished measurement, I fill the datas, that the user gave during the 1st measurement, do the measurement.O.K.
The problem :
When I wanna save, I mean modify the measurement,- delete the unfinished flag, and save the 2nd measurement datas, in the onsaving method Session.IsNewObject(this)=true, that's why the XAF inserts a newrecord, not modify it.
How can I modify this record, and not insert new to database ?
Tanks for the help,
Zoltan
Hi Zoltan.
If you wish to modify an existing record, do not create a new measurement via the New action. Instead, use the FullTextSearch action to find an existing measure, for example.
If the user does not know whether a previous measurement exists, you can create a custom action to simplify the process as follows. Create a ParametrizedAction to accept the ID or a PopupWindowShowAction to show a dialog if you need a complex search. When this action is executed, search for a previous measurement record. If it is found, open the detail view of the measurement record, otherwise create a new measurement instance and open its detail view.
Hi Michael !
In my project induced a lot of problem, to finish it. If I review my questions that asked from the support, it is about 80% about about this project. The project, and the task, that I have to implemet it, is very simple, but the realization in XAF is hard many times.
There are many specialities,- like this problem,- these are NOT exist in any other project, only in this project.
Sorry for this long prolog.
O.K. Is not any other way, workaround for this ?
Explanation : when the user enters the licence plate number = LPN into the first field, he does not know, that exist or not a measurement for this LPN. There are more than 100 measurement per day, and more than 30 1st measurement at the same time. Please see the attavhement.
The users enter the LPN, if exist, it will be a new measurement with finished-flag=false, if the next measurement enter the same LPN, it will modify the record. (that's why I wanted to use the PUFFER table, but if You reread the ticket, I reject using the PUFFER table, because I cannot implement it for my needs, based upon your suggetion.)
I want simplify the user's job : everytime he want to measure, click new measurement button, enter the LPN, if this LPN does not exist save the 1st measurement, if exist, modify the record. I hope it is clear. I have to implement it this way, this is my BOSS command.
I've got an idea, not the best, but fits my needs, I think :
In the 1st measurement save the datas, O.K.
In the 2nd measurement, save the datas, and delete the record, that is same like this, except for the unefinished flag, and the 2nd measurement datas.
How can I implement it, e.g in OnSaving() ? (I need a short sample code, saving…create a new object, find it, and delete…).
2."Instead, use the FullTextSearch action to find an existing measure, for example."
This is not option. Please see the 1.
3."If the user does not know whether a previous measurement exists, you can create a custom action to simplify the process as follows. Create a ParametrizedAction to accept the ID or a PopupWindowShowAction to show a dialog if you need a complex search. When this action is executed, search for a previous measurement record. If it is found, open the detail view of the measurement record, otherwise create a new measurement instance and open its detail view."
Huh…, I will implement this, way only, if I will not any chance to solve this problem, that write it above.
Thanks for the help,
Zoltan
P.S.
I found the http://www.devexpress.com/Support/Center/Question/Details/Q423413.