Welcome 9 2 0 1 Hello Agenda 19/06/2019 Registration & - - PowerPoint PPT Presentation

welcome
SMART_READER_LITE
LIVE PREVIEW

Welcome 9 2 0 1 Hello Agenda 19/06/2019 Registration & - - PowerPoint PPT Presentation

Welcome 9 2 0 1 Hello Agenda 19/06/2019 Registration & Welcome Practical presentations Part 1 Lunch time Abdelhafid El Hour Practical presentations Part 2 Development engineer Q&A with your 4D team 2 9 0 1


slide-1
SLIDE 1

Welcome

2 1 9

Hello

slide-2
SLIDE 2

2 1 9

Agenda

Abdelhafid El Hour

Development engineer

19/06/2019

  • Registration & Welcome
  • Practical presentations Part 1
  • Lunch time
  • Practical presentations Part 2
  • Q&A with your 4D team
slide-3
SLIDE 3

My Town library

slide-4
SLIDE 4

2 1 9

Managing municipal library

slide-5
SLIDE 5

Sharing

slide-6
SLIDE 6

2 1 9

Shared objects / collections

$sharedObject:=New shared object $sharedCollection:=New shared collection $sharedCollection.push($sharedObject)

Locking identifier negative

$sharedObject and $sharedCollection make a shared group. They share the same locking identifier

slide-7
SLIDE 7

2 1 9

Nesting shared object

Shared Object / Collection

  • 27

Shared group

28

Shared group

28

Shared group

28

Shared group

29

Shared group

28

slide-8
SLIDE 8

2 1 9

Create table

Use (Storage) Storage.tables:=New shared collection $tables:=Storage.tables End use Use ($tables) //----------------- BOOK -------------- $table:=New shared object Use ($table) $table.dataclass:="Book" $table.label:="Livre" $table.name:="title" $table.perspective:="Catalogue" $table.panel:="Book_panel" $table.countFormat:="### ### ##0 books;;" $callback:=New shared object $table.callback:=$callback $formula:=New formula(Author_load ) $table.callback.load:=$formula End use end use

Use is necessary

Storage

  • 17

$tables.push($table)

$tables

  • 28

$table

  • 29

$callback

  • 30

30 30

STOP

slide-9
SLIDE 9

2 1 9

Create table

Use (Storage) Storage.tables:=New shared collection $tables:=Storage.tables End use Use ($tables) //----------------- BOOK -------------- $table:=New shared object Use ($table) $table.dataclass:="Book" $table.label:="Livre" $table.name:="title" $table.perspective:="Catalogue" $table.panel:="Book_panel" $table.countFormat:="### ### ##0 books;;" $callback:=New shared object $table.callback:=$callback $formula:=New formula(Author_load ) $table.callback.load:=$formula End use end use

Storage

  • 17

$tables.push($table)

$tables

  • 28

$table

  • 29

$callback

  • 30

29 29 29

slide-10
SLIDE 10

2 1 9

Exception

Storage

  • 17

Objet partagé

  • 28

Collection partagée-29 Shared object Locking identifier negative Objet partagé

30

Objet partagé

30

Objet partagé

30

Storage don’t shard its locking with

  • ther objects
slide-11
SLIDE 11

Panels

slide-12
SLIDE 12

2 1 9

My town library

lb_tables

initialization : sfw_fill_lb_tables

lb_items pup_perspective

clic : sfw_fill_lb_tables clic : sfw_display_item clic : sfw_fill_lb_items

initialization : sfw_fill_lb_items

clic : sfw_fill_lb_items

slide-13
SLIDE 13

2 1 9

Form and subform

Widget in the form of object type ‘Subform container’ OBJECT SET SUBFORM(*;"sf_panel";"Author_panel")

slide-14
SLIDE 14

2 1 9

Form

Form and subform

Subform instance Form Form

How we can access to the ‘Form’ of the subForm ?

C_POINTER($subForm) $subForm:=OBJECT Get pointer(Object named;"sf_panel") $subForm->entity:=Form.entity $subForm->UUID:=Form.UUID $subForm->currentTable:=Form.currentTable

$subForm is a pointer to an object Subform container

slide-15
SLIDE 15

2 1 9

Form Subform instance

Form un subform

Form Form

$evt:=Form event Case of : ($evt=On Data Change) CALL SUBFORM CONTAINER(-1000) End case C_POINTER($subForm) $evt:=Form event Case of : ($evt=-1000) $subForm:=OBJECT Get pointer(Object current) Form.entity:=$subForm->entity Form.UUID:=$subForm->UUID Form.currentTable:=$subForm->currentTable End case

Method object

Code executed in the parent form context Object method of the container

slide-16
SLIDE 16

4D Write Pro

slide-17
SLIDE 17

2 1 9

Reference your texts

Use bookmarks

$section:=WP Get section(Form.booksDoc;$i) $rangeSection:=WP Create range($section;wk start text;wk end text) WP CREATE BOOKMARK($rangeSection;$categoriesfromServer[$i-1].name) ………………………………. $_ptr_bookmarks:=OBJECT Get pointer(Object named;"bookmarks") ARRAY TEXT($_ptr_bookmarks->;0) WP GET BOOKMARKS(Form.booksDoc;$_ptr_bookmarks->)

Form method

Associate a bookmark to a text
slide-18
SLIDE 18

2 1 9

Reference your texts

Use bookmarks

C_OBJECT($wpRange) Case of : (Form event=On Data Change) $_ptr_bookmarks:=OBJECT Get pointer(Object named;"bookmarks") $bookMark:=$_ptr_bookmarks->{$_ptr_bookmarks->} $wpRange:=WP Get bookmark range(Form.booksDoc;$bookMark) WP SELECT(Form.booksDoc;$wpRange) End case

Object method ‘bookmarks’ Range referenced by bookmark Select a range

slide-19
SLIDE 19

2 1 9

Organize your pages with tables

$picture:=ds.Image.get($book.images.thumbnail.record).thumbnail` $WPTableDescription:=WP Insert table($WPRange;wk append) WP Table append row($WPTableDescription;$picture;$book.description) $cells:=WP Table get cells($WPTableDescription;1;1;MAXLONG;MAXLONG) WP SET ATTRIBUTES($cells;wk border color;"white") $fcolumn:=WP Table get columns($WPTableDescription;2;1) WP SET ATTRIBUTES($fcolumn;wk width;"380pt") $scolumn:=WP Table get columns($WPTableDescription;1;1) WP GET ATTRIBUTES($scolumn;wk width;$width) WP SET ATTRIBUTES($WPTableDescription;wk vertical align;wk top) $oPicts:=WP Create picture range($scolumn) WP SET ATTRIBUTES($oPicts;wk width;$width)

Form method

Hide the borders Change the width

  • f the image
slide-20
SLIDE 20

2 1 9

Customize the context menu

Uncheck the context menu

$contextualMenu:=Create menu APPEND MENU ITEM($contextualMenu;ak standard action title) SET MENU ITEM PROPERTY($contextualMenu;-1;Associated standard action;ak copy) APPEND MENU ITEM($contextualMenu;ak standard action title) SET MENU ITEM PROPERTY($contextualMenu;-1;Associated standard action;ak cut) APPEND MENU ITEM($contextualMenu;ak standard action title) SET MENU ITEM PROPERTY($contextualMenu;-1;Associated standard action;ak paste) APPEND MENU ITEM($contextualMenu;"-") APPEND MENU ITEM($contextualMenu;ak standard action title) SET MENU ITEM PROPERTY($contextualMenu;-1;Associated standard action;ak font style) $menuSubSize:=Create menu APPEND MENU ITEM($menuSubSize;ak standard action title) SET MENU ITEM PROPERTY($menuSubSize;-1;Associated standard action;"fontSize?value=10pt") APPEND MENU ITEM($menuSubSize;ak standard action title) SET MENU ITEM PROPERTY($menuSubSize;-1;Associated standard action;"fontSize?value=12pt") APPEND MENU ITEM($menuSubSize;ak standard action title) SET MENU ITEM PROPERTY($menuSubSize;-1;Associated standard action;"fontSize?value=14pt") APPEND MENU ITEM($menuSubSize;ak standard action title) SET MENU ITEM PROPERTY($menuSubSize;-1;Associated standard action;"fontSize?value=16pt") APPEND MENU ITEM($contextualMenu;"Size";$menuSubSize) APPEND MENU ITEM($contextualMenu;"-") APPEND MENU ITEM($contextualMenu;ak standard action title) SET MENU ITEM PROPERTY($contextualMenu;-1;Associated standard action;"visibleHiddenChars") Form.contextualMenu:=$contextualMenu

Use actions

https://doc.4d.com/4Dv17/4D/17.1/Actions-standard.300-4201167.fr.html

Limit users action

Case of : (Form event=On Clicked) If (Contextual click) Dynamic pop up menu(Form.contextualMenu) End if End case
slide-21
SLIDE 21

Serveur Web 4D

slide-22
SLIDE 22

2 1 9

http://monsite.com/books?page=3

Path / Query Parameters

Domain name

‘Path' Path to a resource

Query String

Empire of Magic Dimensions of Humor Linguistic Theories of Humor An Anatomy of Humor Text Types and Corpora License to Laugh The iPhone Pocket Guide Head First PHP MySQL Class Actions Action Theory The God of the Prophets The X-Discipline Essentials of Shinto Identity Poetics Translation Complex Inequality The Pervasive Image Horizons in Hermeneutics The Arts in Education Interacting with Video International Adventures Seven Types of Adventure Tale Frightening Fiction Beyond the Cyborg Emmanuel Levinas Empire of Magic Dimensions of Humor Linguistic Theories of Humor An Anatomy of Humor Text Types and Corpora License to Laugh The iPhone Pocket Dimensions of Humor Linguistic Theories of Humor An Anatomy of Humor Text Types and Corpora License to Laugh The iPhone Pocket Guide Head First PHP

slide-23
SLIDE 23

2 1 9

http://localhost:8080/books/0ougn1

Path / Query Parameters

//4DRouting {"path" : "/books/:permalink", "restrict" : true}

$permalink:=routing_request.pathParams.permalink

Request object

Path parameter

slide-24
SLIDE 24

2 1 9

Load router

//4DRouting {"path" : "/books/:permalink", "restrict" : true}

swfw_load_router

{"permalink" : 1}

slide-25
SLIDE 25

2 1 9

Match urls

//4DRouting {"path" : "/books/:permalink", "restrict" : true}

swfw_findHandlerRequest

http://localhost:8080/books/0ougn1

["books", "0ougn1" ] ["books", ":permalink" ]

slide-26
SLIDE 26

2 1 9

Get path parameters

swfw_dispatcher

http://localhost:8080/books/0ougn1

["books", "0ougn1" ] {"permalink" : "0ougn1"} {"permalink" : 1}

slide-27
SLIDE 27

2 1 9

Path Parameters

C_OBJECT($book) $book:=ds.Book.query("permalink = :1";routing_request.pathParams.permalink).first() If ($book#Null) routing_request.book:=$book.toObject("*,publisher.name, owners.author.firstName, owners.author.lastName") end if <h2 ><!--#4DEVAL routing_request.book.title—-></h2> <p><!--#4DEVAL routing_request.book.description—-></p>

HTML

Get the path parameter Set ‘book’ attribute inside the request object The first entity Entity selection ‘books’

slide-28
SLIDE 28

2 1 9

http://monsite.com/books/?search=balzac

Query Parameters

//4DRouting {"path" : "/books", "restrict" : true}

$motCle:=routing_request.queryParams.search

Query parameter Optional

C_OBJECT($booksEntitySelection) If (OB Is defined(routing_request.queryParams; "search")) $booksEntitySelection:=ds.Book.query("title = :1 or owners.author.firstName = :1 or owners.author.lastName = :1";"@"+routing_request.queryParams.search+"@") Else $booksEntitySelection:=ds.Book.all() End if routing_request._books:=$booksEntitySelection.toCollection("UUID, permalink, title, images, owners.author.firstName, owners.author.lastName")

Check if the parameter exists

slide-29
SLIDE 29

2 1 9

http://monsite.com/books?page=14

Don’t send all your data

swfw_pagination_build ($totalItem;$page)

$totalItem:=$1 // Nombre total d’élément $currentPage:=$2 // La page à affichée $pagination:=New object $pagination.visiblePages:=8 $pagination.itemOnPage:=18 $totalPages:=Int($totalItem/$pagination.itemOnPage) If (Mod($totalItem;$pagination.itemOnPage)#0) $totalPages:=$totalPages+1 End if $half:=Int($pagination.visiblePages/2) $start:=$pagination.currentPage-$half $end:=$start+$pagination.visiblePages-1 $pagination.startItem:=($currentPage-1)*$pagination.itemOnPage $pagination.endItem:=$currentPage*$pagination.itemOnPage routing_request.pagination:=$pagination swfw_load_section ("pages/pagination.shtml")

1 2 3 4 5 6 7 8

Total pages

Le Petit Prince Le Petit Prince Le Rouge et le Noir Le Grand Meaulnes Les Misérables Le Petit Prince Le Rouge et le Noir Le Grand Meaulnes ……… Les Misérables Le Petit Prince Le Rouge et le Noir Le Grand Meaulnes Les Misérables Le Petit Prince Le Rouge et le Noir Le Grand Meaulnes

<ul> <!--#4DEVAL $i:=routing_request.pagination.start—> <!--#4DLOOP ($i<=routing_request.pagination.end))--> <li><a href="#"><!--#4DEVAL $i—></a></li> <!--#4DEVAL $i:=$i+1--> <!—#4DENDLOOP—> </ul>

Use pagination

total d’item Books or Albums

slide-30
SLIDE 30

Q&A

slide-31
SLIDE 31

ORDA

slide-32
SLIDE 32

2 1 9

Verrouillage des enregistrements

Pessimiste Optimiste

C_OBJECT($info) 
 C_BOOLEAN($done)
 $entity:=ds.Employee(5)
 Repeat 
 $entity.salary:=100
 $info:=$entity.save()
 $done:=$info.success
 If (Not($done))
 $entity.reload()
 End if
 Until ($done) C_OBJECT($info) 
 $entity:=ds.Employee(5)
 $info:=$entity.lock()
 If ($info.success)
 $entity.salary:=100
 $entity.save()
 $entity.unlock() 
 End if

Pose du verrou Sauvegarde Libération du verrou Modification sans verrou Tentative de sauvegarde Test de la réussite

Ce schéma est un des schémas possibles

slide-33
SLIDE 33

2 1 9

Status object

$info.success $info.status

True False

dk status locked dk status stamp has changed dk status wrong permission dk status serious error dk status success

slide-34
SLIDE 34

2 1 9

Verrouillage des enregistrements

dk status locked dk status stamp has changed dk status wrong permission dk status serious error … dk status locked 
 Le verrou peut provenir de :

  • un .lock pessimiste dans un autre process
  • une modification dans une transaction en cours
  • un chargement en lecture écriture par le langage classique

dk status stamp has changed 
 Le changement de stamp peut provenir :

  • un .save réalisé avec succès
  • une sauvegarde par le langage classique
  • un update par le SQL

dk status wrong permission 
 A venir … dk status serious error 


  • Erreur d'écriture sur le disque (disque plein …)
  • Erreur dans le trigger (programmée ou non)
slide-35
SLIDE 35

2 1 9

Déverrouillage des enregistrements

Quand .unlock est appelé A la fin du process ayant posé le verrou Quand le ref comptage de l'entité passe à zéro

slide-36
SLIDE 36

4D View Pro

slide-37
SLIDE 37

Envoyer un email

slide-38
SLIDE 38

2 1 9

Attacher des pièces jointes

$entity:=ds.Borrowing_cart.query("current_state = :1";7).first() $file:=Get 4D folder(HTML Root folder)+"pages"+Folder separator+"emailTemplate.shtml" $templateHtml:=Document to text($file) PROCESS 4D TAGS($templateHtml;$emailBody;$entity;"cid:LivresRetard") $server:=New object $server.host:="smtp.gmail.com" $server.port:=465 $server.user:="woroldtour2019@gmail.com" $server.password:="20194Dworldtour" $transporter:=SMTP New transporter($server) $email:=New object $email.subject:="Panier en retard $email.from:="woroldtour2019@gmail.com" $email.to:="abdelhafid.elhour@4d.com" $logopth:=Get 4D folder(HTML Root folder)+"town2.jpg" $niceDay:=Get 4D folder(HTML Root folder)+"niceDay.jpg" $email.attachments:=New collection $email.attachments.push(MAIL New attachment($logopth;"Livre en retars";"LivresRetard";"image/jpeg";mail disposition inline)) $email.attachments.push(MAIL New attachment($niceDay;"Have a nice day.jpg")) $email.htmlBody:=$emailBody $status:=$transporter.send($email) If (Not($status.success)) ALERT("Une erreur est survenue pendant l'envoi de l'e-mail : "+$status.message) End if Personnaliser le corps de l’email avec une page HTML Ajouter une pièce jointe ‘inline’ PJ lien dans le message
slide-39
SLIDE 39

4D for iOS

slide-40
SLIDE 40

2 1 9

Avant de commencer …

De quoi avant nous besoin ? Faire un slide avec les différents ingrédients nécessaires

  • 4D v17 R? ou 4D v 17
  • Swift
  • Javascript ? Bonne connaissances
  • CSS ? Coloration ou niveau pro ?
slide-41
SLIDE 41

merci et à bientôt !