public ScriptObject(Object obj, SqlAction act) { myobject = obj; myAction = act; if (myAction.SqlActionId != SqlAction.Delete && myAction.SqlActionId != SqlAction.Alter && myAction.SqlActionId != SqlAction.Create) { throw new ArgumentException("Action is only in CUD values"); } }
public void Edit(Object objectEdited) { objectEdited.ObjectDeleted = false; objectEdited.ObjectEmpty = false; using var cnn = new DatabaseConnection(); cnn.Execute(Object.SQLUpdate, objectEdited); if (objectEdited.GetTypeObject().TypeObjectNeedColumnDefinition) { // TODO : Add synchronisation des colonnes Here } AddScriptToObjectAction(objectEdited, SqlAction.Alter); }
public void Delete(Object objectDel, int numberOfImplementation) { objectDel.ObjectDeleted = true; string sql = numberOfImplementation > 0 ? ObjectWithClientSpecific.SQLDelete : Object.SQLDelete; using var cnn = new DatabaseConnection(); if (objectDel.GetTypeObject().TypeObjectNeedColumnDefinition) { cnn.Execute(ColumnDefinition.SQLDelete, objectDel); } cnn.Execute(sql, objectDel); AddScriptToObjectAction(objectDel, SqlAction.Delete); }
private void AddScriptToObjectAction(Object currentObjectEdited, int action) { // Ajouter un script à la version var script = new ScriptObject(currentObjectEdited, new SqlAction() { SqlActionId = action }); var crudScript = new Script() { ScriptText = script.ToString(), VersionId = currentObjectEdited.VersionId, }; var scriptId = cnn.ExecuteScalar(Script.SQLInsert, crudScript); // Ajouter l'anlyse pour ce script var analyzer = SqlAnalyzer.Analyse(scriptId, crudScript.ScriptText); analyzer.Valide = EValidation.Valide; analyzer.Save(cnn); }