Esempio n. 1
0
 public static void WriteLog(String Value, Boolean NewLogGroup, Core.Log.LogIdentifier LogType)
 {
     if (LogStream == null)
     {
         CreateLog(LogType.ToString());
         LogStream.WriteLine("");
         LogStream.WriteLine("\"PrestaConnect version : " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString() + "\"");
         LogStream.WriteLine("");
         LogStream.WriteLine("\"Informations de connexion :\"");
         LogStream.WriteLine("\"Serveur d'exécution : " + Environment.MachineName + "\"");
         LogStream.WriteLine("\"Domaine réseau : " + Environment.UserDomainName + "\"");
         LogStream.WriteLine("\"Session utilisateur de : " + Environment.UserName + "\"");
         LogStream.WriteLine("\"Connexion base de données PrestaConnect : " + Properties.Settings.Default.PRESTACONNECTConnectionString + "\"");
         LogStream.WriteLine("\"Connexion base de données Sage : " + Properties.Settings.Default.SAGEConnectionString + "\"");
         LogStream.WriteLine("\"Connexion ODBC Sage : " + Properties.Settings.Default.SAGEDSN + " - " + Properties.Settings.Default.SAGEUSER.Replace("<", "&lt;").Replace(">", "&gt;") + "\"");
         LogStream.WriteLine("");
     }
     else if (NewLogGroup)
     {
         LogStream.WriteLine("\"--------------------------------------------------------\"");
         LogStream.WriteLine("\"--------------------------------------------------------\"");
     }
     if (NewLogGroup)
     {
         LogStream.WriteLine("");
         LogStream.WriteLine("\"" + DateTime.Now.ToString("yyyy/MM/dd HH-mm") + "\"");
         LogStream.WriteLine("");
         LogStream.WriteLine("\"Utilisateur : " + Environment.UserName + "\"");
         LogStream.WriteLine("");
     }
     LogStream.WriteLine(Value);
 }
Esempio n. 2
0
        public static void SendLog(List <String> log, Boolean UI, Core.Log.LogIdentifier LogType)
        {
            if (log.Count > 0)
            {
                if (Core.Global.GetConfig().TransfertSendAdminResultReport || LogType != Core.Log.LogIdentifier.TransfertClient)
                {
                    bool   send         = false;
                    string msg_not_send = "Compte mail administrateur invalide";
                    if (!String.IsNullOrWhiteSpace(Core.Global.GetConfig().AdminMailAddress) && Core.Global.IsMailAddress(Core.Global.GetConfig().AdminMailAddress, Parametres.RegexMail.lvl08_lUdS))
                    {
                        send = Core.Log.SendLogMail(log, Core.Global.GetConfig().AdminMailAddress, out msg_not_send, LogType);
                    }
                    if (!send)
                    {
                        log.Add(Core.Log.LogLineSeparator);
                        log.Add("PC99- Échec d'envoi du log par mail : " + msg_not_send);

                        if (UI)
                        {
                            // TODO si UI affichage log dans une fenetre
                            MessageBox.Show("Échec d'envoi du log par mail !\nLe log va être écrit dans un fichier !", "", MessageBoxButton.OK, MessageBoxImage.Error);
                            Core.Log.WriteSpecificLog(log, LogType);
                            Core.Log.OpenDirectory(Core.Log.LogDirectory);
                        }
                        else
                        {
                            Core.Log.WriteSpecificLog(log, LogType);
                            Core.Log.OpenDirectory(Core.Log.LogDirectory);
                        }
                    }
                }
                else
                {
                    Core.Log.WriteSpecificLog(log, LogType);
                }
            }
        }