예제 #1
0
        /// <summary>
        /// This method will process all the files within the queue.
        /// </summary>
        private void ProcessFile(string fileName)
        {
            try
            {
                FileInfo file = new FileInfo(fileName);
                // Check that the file can be openned
                FileStream fs = file.Open(FileMode.Open, FileAccess.Read);
                fs.ReadByte();
                fs.Close();
                if (OnItemFound != null)
                {
                    FolderItemEventArgs fia = new FolderItemEventArgs(file);
                    OnItemFound(this, fia);
                }
                Interlocked.Increment(ref m_total);
            }
            catch (IOException e)
            {
                System.Diagnostics.Trace.TraceError("File is in use - " + e.Message);
                StringBuilder sb = new StringBuilder();
                sb.AppendFormat(Properties.Resources.AUDIT_PROCESSEX, fileName,
                    e.Message);

                System.Diagnostics.Trace.WriteLine(sb.ToString(), "AuditInfo");
            }
            catch (UnauthorizedAccessException e)
            {
                System.Diagnostics.Trace.TraceError("Cannot access file/folder - " + e.Message);
            }
        }
예제 #2
0
        void OnFileSystemItemFound(object sender, FolderItemEventArgs e)
        {
            if (!m_continue)
                return;

            //need to notify clients even when we could do nothing with message.
            if (null == e.Uro)
            {
                //Skip the actual call to the audit engine. 
                //Clients need to be able to handle null notifications.
                m_traceClient.NotifyItemAudited(null);
            }
            else if (m_engine != null)
            {
                StringBuilder info = new StringBuilder();
                try
                {
                    info.AppendFormat(Properties.Resources.AUDIT_PROCESS, e.FileName);
                    System.Diagnostics.Trace.WriteLine(info.ToString(), "AuditInfo");
                    Logging.Trace.WriteLine("Passing a File as Message to the policy engine: \"" + e.FileName + "\"", "TraceAuditHelper.m_emailScanner_MailItem");

					IPolicyResponseObject pro = m_engine.ProcessConditions(Workshare.Policy.RunAt.Client, e.Uro);
					OnAuditMail(new AuditEventArgs(pro));


                }
                catch (Exception ex)
                {
                    info.Remove(0, info.Length);
                    info.AppendFormat(Properties.Resources.AUDIT_PROCESSEX, e.FileName, ex.Message);
                    System.Diagnostics.Trace.WriteLine(info.ToString(), "AuditInfo");
                    m_traceClient.NotifyItemAudited(null);
                    Logging.Trace.WriteLine(ex.Message, "TraceAuditManager.OnFileSystemItemFound Exception");
                }
            }
            e.Dispose();
        }