EaseFilter Demo Project
SharedFileAccessLogForm.cs
Go to the documentation of this file.
1 //
3 // (C) Copyright 2011 EaseFilter Technologies Inc.
4 // All Rights Reserved
5 //
6 // This software is part of a licensed software product and may
7 // only be used or copied in accordance with the terms of that license.
8 //
10 
11 using System;
12 using System.Collections.Generic;
13 using System.ComponentModel;
14 using System.Data;
15 using System.Drawing;
16 using System.Linq;
17 using System.Text;
18 using System.IO;
19 using System.Windows.Forms;
20 
22 
23 namespace SecureAgent
24 {
25  public partial class SharedFileAccessLogForm : Form
26  {
27  public string accessLogStr = string.Empty;
28  public bool initialized = false;
29 
31  {
32  this.StartPosition = FormStartPosition.CenterParent;
33  InitializeComponent();
34  InitListView();
35  }
36 
37  public void InitListView()
38  {
39 
40  listView_AccessLog.Clear();
41  //create column header for ListView
42  listView_AccessLog.Columns.Add("Status", 80, System.Windows.Forms.HorizontalAlignment.Left);
43  listView_AccessLog.Columns.Add("AccessTime",160, System.Windows.Forms.HorizontalAlignment.Left);
44  listView_AccessLog.Columns.Add("UserName",100, System.Windows.Forms.HorizontalAlignment.Left);
45  listView_AccessLog.Columns.Add("ProcessName",100, System.Windows.Forms.HorizontalAlignment.Left);
46  listView_AccessLog.Columns.Add("FileName",150, System.Windows.Forms.HorizontalAlignment.Left);
47  listView_AccessLog.Columns.Add("Location", 200, System.Windows.Forms.HorizontalAlignment.Left);
48  listView_AccessLog.Columns.Add("Description", 350, System.Windows.Forms.HorizontalAlignment.Left);
49 
50  try
51  {
52  if( accessLogStr.Length == 0 )
53  {
54  return;
55  }
56 
57  string accessLog = FilterAPI.AESEncryptDecryptStr(accessLogStr, FilterAPI.EncryptType.Decryption);
58  StringReader sr = new StringReader(accessLog);
59 
60  while (true)
61  {
62  string accessInfo = sr.ReadLine().Trim();
63  if (string.IsNullOrEmpty(accessInfo))
64  {
65  break;
66  }
67 
68  try
69  {
70 
71  string[] infos = accessInfo.Split(new char[] { '|' });
72 
73  if (infos.Length < 7)
74  {
75  continue;
76  }
77 
78  ListViewItem lvItem = new ListViewItem();
79  string[] listData = new string[listView_AccessLog.Columns.Count];
80 
81  if (infos[0].Trim() == "1")
82  {
83  listData[0] = "Authorized";
84  }
85  else
86  {
87  listData[0] = "Denied";
88  listData[6] = infos[6].Trim();
89  }
90 
91  long accessTimeL = 0;
92 
93  if (long.TryParse(infos[1].Trim(), out accessTimeL))
94  {
95  DateTime accessTime = DateTime.FromFileTime(accessTimeL);
96  listData[1] = accessTime.ToString("F");
97  }
98 
99  listData[2] = infos[2].Trim();
100  listData[3] = infos[3].Trim();
101  listData[4] = infos[4].Trim();
102  listData[5] = infos[5].Trim();
103 
104  lvItem = new ListViewItem(listData, 0);
105 
106  if (infos[0].Trim() == "0")
107  {
108  lvItem.BackColor = Color.LightGray;
109  lvItem.ForeColor = Color.Red;
110  }
111 
112 
113  listView_AccessLog.Items.Add(lvItem);
114  }
115  catch
116  {
117  }
118  }
119 
120  }
121  catch
122  {
123  }
124  }
125 
126  private void AccessLogForm_Shown(object sender, EventArgs e)
127  {
128  InitListView();
129  }
130 
131 
132  private void toolStripButton1_Click(object sender, EventArgs e)
133  {
134  string logStr = string.Empty;
135  string lastError = string.Empty;
136 
137  //get access log from remote server
138  bool retVal = false;//GetAccessLog(AccountForm.accountName, AccountForm.password, ref logStr, ref lastError);
139 
140  if (retVal)
141  {
142  accessLogStr = logStr;
143  InitListView();
144  }
145 
146  }
147 
148  private void toolStripButton_ClearMessage_Click(object sender, EventArgs e)
149  {
150  string lastError = string.Empty;
151 
152  //clear access log from remote server
153  bool retVal = false;//ClearAccessLog(AccountForm.accountName, AccountForm.password,ref lastError);
154 
155  if (retVal)
156  {
157  accessLogStr = string.Empty;
158  InitListView();
159  }
160  }
161 
162 
163  }
164 }

Social Network


Services Overview

Architect, implement and test file system filter drivers for a wide range of functionality. We can offer several levels of assistance to meet your specific.

Contact Us

You are welcome to contact us for salse or partnership.

Sales: sales@easefilter.com
Support: support@easefilter.com
Info: info@easefilter.com