Ejemplo n.º 1
0
        public static void DeleteLogFile()
        {
            PWEventLogging.GetObject().MyEvents.WriteEntry(MethodBase.GetCurrentMethod().Name + " " + DateTime.Now.ToString("dd-YYYY-mm HH:MM:ss"), EventLogEntryType.Information);

            try
            {
                string[] fileArray = Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + Properties.Resources.TraceFolder + "PlanningWand");


                if (fileArray.Length > 0)
                {
                    if (MessageBox.Show("Please confirm deletion of " + fileArray.Length.ToString() + " files in the " +
                                        Environment.SpecialFolder.LocalApplicationData.ToString() + Properties.Resources.TraceFolder.ToString() +
                                        " folder?", "Delete trace files", MessageBoxButtons.OK) == DialogResult.OK)
                    {
                        foreach (string aFileName in fileArray)
                        {
                            File.Delete(aFileName);
                        }
                    }
                }
                else
                {
                    MessageBox.Show("No files to delete in the " + Environment.SpecialFolder.LocalApplicationData.ToString() +
                                    Properties.Resources.TraceFolder.ToString(), "Trace file deletion", MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception ex)
            {
                PWEventLogging.GetObject().MyEvents.WriteEntry(ex.Message + " Clearing trace files", EventLogEntryType.Error);
                MessageBox.Show("Unable to clear trace files. " + ex.Message, "Trace file deletion error", MessageBoxButtons.OK, MessageBoxIcon.Exclamation);
            }

            PWEventLogging.GetObject().MyEvents.WriteEntry(MethodBase.GetCurrentMethod().Name + " " + DateTime.Now, EventLogEntryType.SuccessAudit);
        }
Ejemplo n.º 2
0
 /// <summary>
 ///   Make accessor Thread-safe
 /// </summary>
 /// <returns></returns>
 public static PWEventLogging GetObject()
 {
     if (PWEventLogging.m_pwEventLogging == null)
     {
         lock (syncRoot)
         {
             if (PWEventLogging.m_pwEventLogging == null)
             {
                 PWEventLogging.m_pwEventLogging = new PWEventLogging();
             }
         }
     }
     return(PWEventLogging.m_pwEventLogging);
 }