// - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -

        public static void WriteLineDB(DBSQLViewModel dBSQLViewModel, AuditTrailViewModel sender, AuditTrail message)
        {
            if (dBSQLViewModel == null)
            {
                return;
            }

            try
            {
                DB_SQL.Insert(dBSQLViewModel, message);

                if (!string.IsNullOrEmpty(dBSQLViewModel.LastError))
                {
                    Debug.WriteLine("AuditTrailViewModel LastError: " + dBSQLViewModel.LastError + Environment.NewLine
                                    + "AuditTrailViewModel LastQuery: " + dBSQLViewModel.LastQuery);

                    //Log.Debug(new AuditTrail
                    //{
                    //   Message = "AuditTrailViewWriter LastError: " + dBSQLViewModel.LastError + Environment.NewLine
                    //                                       + "AuditTrailViewWriter LastQuery: " + dBSQLViewModel.LastQuery
                    //});
                }
                ;
            }
            catch (Exception ex)
            {
                System.Diagnostics.Debug.WriteLine("AuditTrailViewModel: " + ex.Message);

                //Log.Debug(new AuditTrail
                //{
                //   Message = "AuditTrailViewWriter: " + ex.Message
                //});
            };
        }
        // - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -  - -

        public static bool EndWriteDB(DBSQLViewModel dBSQLViewModel, Int64 parent, ErrorLevel errorLevel, string message, string dataOutType, string dataOut)
        {
            long Ticks = DateTime.Now.Ticks;

            var at = DB_SQL.QueryFirst <AuditTrail>(dBSQLViewModel, "select * from AuditTrail where PK=" + parent);

            if (at != null)
            {
                at.Level       = errorLevel;
                at.Ticks       = Ticks - at.Ticks;
                at.DataOutType = dataOutType;
                at.DataOut     = dataOut;
                at.Parent      = -1; // ChM 20180514 pour simplifier requetes exploitations begin sans end

                var endAT = new AuditTrail();
                endAT.Application = at.Application;
                endAT.TerminalID  = at.TerminalID;
                endAT.TerminalIP  = at.TerminalIP;
                endAT.FKUser      = at.FKUser;
                endAT.ItemID      = at.ItemID;
                endAT.ItemType    = at.ItemType;
                endAT.IsBusiness  = at.IsBusiness;
                endAT.Tag         = at.Tag;
                endAT.Parent      = parent;
                endAT.Message     = message;
                endAT.Level       = errorLevel;
                endAT.DataOutType = dataOutType;
                endAT.DataOut     = dataOut;

                DB_SQL.Insert(dBSQLViewModel, endAT);

                return(DB_SQL.Update(dBSQLViewModel, at));
            }
            else
            {
                return(false);
            };
        }