/
CL_WORKFLOW.cs
137 lines (105 loc) · 4.67 KB
/
CL_WORKFLOW.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading;
namespace PharmaProject
{
/// <summary>
/// COUCHE MÉTIER (Workflow, Mappage, Composant Technique). Ce sont les services
/// </summary>
class CL_WORKFLOW
{
private STR_MSG iMsg;
private IWorkflow work;
public STR_MSG Redirect(STR_MSG oMsg)
{
if (oMsg.token == "Pharmacien")
{
// services pharmaciens
}
else if (oMsg.token == "Fournisseur")
{
// services Fournisseurs
}
else if (oMsg.token == "Preparateur")
{
// services préparateurs
}
else
{
// services clients
if ((oMsg.Invoke == "CommandeClient") && (oMsg.App_Name == "PharmaProject_v1"))
{
// 1) RecupIDCLient
this.work = new CL_WF_RecupIDClient();
STR_MSG requete = work.exec(oMsg);
if(requete.Info != "OK")
{
this.iMsg = CL_MESSAGE_Factory.msg_factory("", null, "Erreur lors de la connexion : " + requete.Info, "", "", true, "");
}
else
{
// 2) CreerCommandeCliente
int ID_CLIENT = (int)requete.Data[0];
this.work = new CL_WF_CreerCommandeCliente();
object[] data = new object[] { oMsg.Data[0], ID_CLIENT, oMsg.Data[1] }; // nom utilisateur + ID_CLIENT + Liste de Medics
requete = CL_MESSAGE_Factory.msg_factory("", data, "", "", "", true, "");
requete = this.work.exec(requete);
// on a récupéré l'ID de la commande, on peut remplir la commande
if (requete.Info == "OK")
{
// 3) PasserCommandeCliente
int ID_COMMANDE = (int)requete.Data[0];
this.work = new CL_WF_PasserCommandeCliente();
List<string> ls = (List<string>)oMsg.Data[1];
foreach (string s in ls)
{
data = new object[] { oMsg.Data[0], s, ID_COMMANDE}; // nom utilisateur + nomMedic + ID_CLIENT
requete = CL_MESSAGE_Factory.msg_factory("", data, "", "", "", true, "");
STR_MSG retour = this.work.exec(requete);
if (retour.Info != "OK")
{
break;
}
this.iMsg = retour;
}
}
}
}
}
// SERVICES GÉNÉRAUX
// Connexion à la BDD
#region Connexion BDD
if ((oMsg.Invoke == "Connexion") && (oMsg.App_Name == "PharmaProject_v1"))
{
this.work = new CL_WF_Connect();
STR_MSG retourMsg = work.exec(oMsg);
// si la connexion a bien réussie
if (retourMsg.Info == "OK")
{
// vérification des droits
this.work = new CL_WF_VerificationDroits();
retourMsg = work.exec(oMsg);
this.iMsg = CL_MESSAGE_Factory.msg_factory("", retourMsg.Data, "OK", "", "", true, ""); // on renvoit le type d'utilisateur
}
else
{
this.iMsg = CL_MESSAGE_Factory.msg_factory("", null, "Erreur lors de la connexion : " + retourMsg.Info, "", "", true, "");
}
}
#endregion
else if ((oMsg.Invoke == "createUser") && (oMsg.App_Name == "PharmaProject_v1"))
{
this.work = new CL_WF_CreerUtilisateur();
this.iMsg = work.exec(oMsg);
}
else if ((oMsg.Invoke == "ListerMedics") && (oMsg.App_Name == "PharmaProject_v1"))
{
this.work = new CL_WF_ListerMedicaments();
this.iMsg = work.exec(oMsg);
}
return this.iMsg;
}
}
}