public void fillTheLogsByMonth(string month) { int logStartX = 3; int logStartY = 3; removePanelControls(); if (LogOperations.areThereLogsOfThisUser(activeUser)) { Dictionary <string, string> LogInfo = LogOperations.getThisUsersLogsInfo(activeUser); DirectoryInfo DirInfo = new DirectoryInfo(Application.StartupPath + @"\Data\Logs"); FileInfo[] Files = DirInfo.GetFiles("*.txt"); for (int i = 0; i < Files.Length; i++) { if (Files[i].Name.Contains(Encryption.MD5encryption(this.activeUser))) { string[] info = LogInfo[Files[i].Name.Replace(Encryption.MD5encryption(this.activeUser), "").Replace(".txt", "")].Split('@'); string[] date = info[2].Split('/'); LogOperations.Month value = (LogOperations.Month) int.Parse(date[1]); if (value.ToString() == month) { logStartX += 150; if (logStartX > 900) { logStartX = logStartX % 900; logStartY += 200; } createLog(logStartX, logStartY, info[0]); } } } } sortText.Text = "Sorted by " + Sort + " : " + month; }
public void fillTheLogsByName(string name) { int res = 0; int logStartX = 3; int logStartY = 3; logPanel.Controls.Clear(); NewLog newLogControl = new NewLog(); newLogControl.Width = 115; newLogControl.Height = 115; newLogControl.Location = new Point(3, 3); newLogControl.MouseClick += newLog1_MouseClick; logPanel.Controls.Add(newLogControl); if (LogOperations.areThereLogsOfThisUser(activeUser)) { Dictionary <string, string> LogInfo = LogOperations.getThisUsersLogsInfo(activeUser); DirectoryInfo DirInfo = new DirectoryInfo(Application.StartupPath + @"\Data\Logs"); FileInfo[] Files = DirInfo.GetFiles("*.txt"); for (int i = 0; i < Files.Length; i++) { if (Files[i].Name.Contains(Encryption.MD5encryption(this.activeUser))) { string[] info = LogInfo[Files[i].Name.Replace(Encryption.MD5encryption(this.activeUser), "").Replace(".txt", "")].Split('@'); if ((info[0].Contains(name) || info[0] == name) && Logs.ContainsValue(info[0])) { logStartX += 150; if (logStartX > 900) { logStartX = logStartX % 900; logStartY += 200; } createLog(logStartX, logStartY, info[0]); res++; } } } } sortText.Text = "Sorted by name : " + name; result = res; }
/* Algorithm explanation of fillTheLogsBy.... functions * * If there is any logs of the current user * first takes a dictionary that haves encrypted and decrypted versions of files name * after that takes every logs that has been created by any user * each log that contains encrypted version of current user name * decrypt the text name and reach the log name and its selected criteria * after that if logs selecte criteria and users selected criteria matches * then that logs getting created by its decrypted names */ //Fill the panel with logs that has selected criteria public void fillTheLogsByTag(string tag) { int logStartX = 3; int logStartY = 3; removePanelControls(); if (LogOperations.areThereLogsOfThisUser(activeUser)) { Dictionary <string, string> LogInfo = LogOperations.getThisUsersLogsInfo(activeUser); DirectoryInfo DirInfo = new DirectoryInfo(Application.StartupPath + @"\Data\Logs"); FileInfo[] Files = DirInfo.GetFiles("*.txt"); for (int i = 0; i < Files.Length; i++) { if (Files[i].Name.Contains(Encryption.MD5encryption(this.activeUser))) { string[] info = LogInfo[Files[i].Name.Replace(Encryption.MD5encryption(this.activeUser), "").Replace(".txt", "")].Split('@'); string[] tags = info[1].Split('*'); List <string> tagList = new List <string>(); foreach (string s in tags) { if (s.Length > 0) { tagList.Add(s.Replace("\n", "")); } } if (tagList.Contains(tag)) { logStartX += 150; if (logStartX > 900) { logStartX = logStartX % 900; logStartY += 200; } createLog(logStartX, logStartY, info[0]); } } } } sortText.Text = "Sorted by " + Sort + " : " + tag; }
//Fill the panel with all logs that user have public void fillTheLogs() { /* If there is any logs of the current user * first takes a dictionary that haves encrypted and decrypted versions of files name * after that takes every logs that has been created by any user * each log that contains encrypted version of current user name * decrypt the text name and reach the log name after that logs are created by their names */ int logStartX = 3; int logStartY = 3; removePanelControls(); if (LogOperations.areThereLogsOfThisUser(activeUser)) { Dictionary <string, string> LogInfo = LogOperations.getThisUsersLogsInfo(activeUser); DirectoryInfo DirInfo = new DirectoryInfo(Application.StartupPath + @"\Data\Logs"); FileInfo[] Files = DirInfo.GetFiles("*.txt"); string x = ""; for (int i = 0; i < Files.Length; i++) { if (Files[i].Name.Contains(Encryption.MD5encryption(this.activeUser))) { x = Files[i].Name; x = x.Replace(".txt", ""); x = x.Remove(x.Length - 32, 32); string[] info = LogInfo[x].Split('@'); logStartX += 150; if (logStartX > 900) { logStartX = logStartX % 900; logStartY += 200; } createLog(logStartX, logStartY, info[0]); } } } sortText.Text = "All"; }