Exemplo n.º 1
0
        public IEnumerable <LogLineView> GetLogLines()
        {
            var repo      = new DisconnectedRepository();
            var ipDetails = repo.GetIpDetails();
            var lines     = repo.GetLogLines();
            var providers = new Providers(ipDetails);



            var result = lines.Select(p => new LogLineView
            {
                Date          = p.Date.ToString("MM/dd/yyyy"),
                Time          = p.Time,
                IpClient      = p.IpClient,
                MediaItem     = p.MediaItem,
                IspProvider   = providers.GetValue(p.IpClient).IspProvider,
                Country       = providers.GetValue(p.IpClient).Country,
                State         = providers.GetValue(p.IpClient).State,
                Location      = providers.GetValue(p.IpClient).Location,
                IpDetailId    = providers.GetValue(p.IpClient).IpDetailId,
                Client        = p.Client,
                ClientVersion = p.ClientVersion,
                Platform      = p.Platform,
                IsHidden      = providers.GetValue(p.IpClient).IsHidden
            });



            return(result);
        }
Exemplo n.º 2
0
        public void Restore(string filePath)
        {
            var repo   = new DisconnectedRepository();
            var reader = new BackupReader();

            var ipDetails = reader.ParseIpDetails(filePath);
            var files     = reader.ParseLogFiles(filePath);
            var lines     = reader.ParseLogLines(filePath);



            repo.ClearTables();

            foreach (var detail in ipDetails)
            {
                repo.AddNewIpDetail(detail);
            }


            foreach (var file in files)
            {
                repo.AddNewLogFile(file);
            }


            foreach (var line in lines)
            {
                repo.AddNewLogLine(line);
            }
        }
Exemplo n.º 3
0
        public IpDetail GetIpDetailById(string id)
        {
            var repo   = new DisconnectedRepository();
            var detail = repo.GetIpDetailById(new Guid(id));

            return(detail);
        }
Exemplo n.º 4
0
        private IEnumerable <LogFile> GetLogFiles()
        {
            var repo  = new DisconnectedRepository();
            var files = repo.GetLogFiles();

            return(files);
        }
Exemplo n.º 5
0
        public IEnumerable <IpDetail> GetIpDetails()
        {
            var repo      = new DisconnectedRepository();
            var ipDetails = repo.GetIpDetails()
                            .OrderBy(p => p.IpNumber).ToList();

            return(ipDetails);
        }
Exemplo n.º 6
0
        private IEnumerable <LogLine> GetLogLinesByFileId(Guid id)
        {
            var repo  = new DisconnectedRepository();
            var files = repo.GetLogLinesByFileId(id);


            return(files);
        }
Exemplo n.º 7
0
        public void ScanFolder()
        {
            string searchPattern = SearchPattern.Log;
            var    repo          = new DisconnectedRepository();
            var    fileProcessor = new FileProcessor();

            LocalSetting setting        = repo.GetLocalSettings();
            string       folderPath     = @"" + setting.FolderPath;
            var          filesToProcess = fileProcessor.FindNewFiles(folderPath, searchPattern);

            var ipDetails = repo.GetIpDetails();

            List <string> ipNumbers        = ipDetails.Select(p => p.IpNumber).ToList();
            List <string> scannedIpNumbers = new List <string>();


            Guid id = new Guid();

            var logProcessor = new LogProcessor();

            foreach (var logFile in filesToProcess)
            {
                var linesToProcess = logProcessor.FindNewlogLines(logFile);
                var fileInDatabase = repo.GetLogFileByFileName(logFile.FileName);

                if (fileInDatabase != null)
                {
                    id = fileInDatabase.LogFileId;
                }
                else
                {
                    id = logFile.LogFileId;
                    repo.AddNewLogFile(logFile);
                }


                foreach (var logLine in linesToProcess)
                {
                    scannedIpNumbers.Add(logLine.IpClient);

                    logLine.LogFileId = id;

                    repo.AddNewLogLine(logLine);
                }
            }

            var newIpNumbers = scannedIpNumbers.Except(ipNumbers);

            foreach (var item in newIpNumbers)
            {
                var ipDetail = new IpDetail();
                ipDetail.IpNumber = item;
                repo.AddNewIpDetail(ipDetail);
                Console.WriteLine(item);
            }
        }
Exemplo n.º 8
0
        public void CreateIpDetail(string ipNumber, string ispProvider, string country, string location, string state)
        {
            var repo = new DisconnectedRepository();

            repo.AddNewIpDetail(new IpDetail {
                IpNumber    = ipNumber,
                IspProvider = ispProvider,
                Country     = country,
                Location    = location,
                State       = state
            });
        }
Exemplo n.º 9
0
        public void SaveSetting(LocalSetting localSetting)
        {
            var repo = new DisconnectedRepository();

            var setting = repo.GetLocalSettings();

            if (setting != null)
            {
                repo.EditLocalSetting(localSetting);
            }
            else
            {
                repo.AddNewLocalSetting(localSetting);
            }
        }
Exemplo n.º 10
0
        public void RestoreDetails(string filePath)
        {
            var repo   = new DisconnectedRepository();
            var reader = new BackupReader();

            var ipDetails = reader.ParseIpDetails(filePath);



            repo.ClearDetailTable();

            foreach (var detail in ipDetails)
            {
                repo.AddNewIpDetail(detail);
            }
        }
Exemplo n.º 11
0
        public IEnumerable <string> GetBackups()
        {
            var repo = new DisconnectedRepository();
            IEnumerable <string> result = new  List <string>();
            var directorySearcher       = new DirectorySearcher();
            var setting = repo.GetLocalSettings();


            if (setting != null)
            {
                result = directorySearcher.ScanFolder(setting.BackupFolder, SearchPattern.Xml);
            }



            return(result);
        }
Exemplo n.º 12
0
        public void BackupDetails()
        {
            var repo         = new DisconnectedRepository();
            var ipDetails    = repo.GetIpDetails();
            var files        = repo.GetLogFiles();
            var lines        = repo.GetLogLines();
            var setting      = repo.GetLocalSettings();
            var backupWriter = new BackupWriter(ipDetails, lines, files, setting);


            var time = DateTime.Now.ToString("yyyy.dd.mm.HH.mm");

            var path     = setting.BackupFolder;
            var fileName = path + setting.BackupName + "_details_" + time + BackupFormat.Xml;

            backupWriter.BackupIpDetails(fileName);
        }
Exemplo n.º 13
0
        public void EditIpDetail(string id, string ipNumber, string ispProvider, string country, string location, string state, bool IsHidden, string alias)
        {
            var      repo   = new DisconnectedRepository();
            IpDetail detail = new IpDetail
            {
                IpNumber    = ipNumber,
                IspProvider = ispProvider,
                Country     = country,
                Location    = location,
                State       = state,
                IpDetailId  = new Guid(id),
                IsHidden    = IsHidden,
                Alias       = alias
            };

            repo.EditIpDetail(detail);
        }
Exemplo n.º 14
0
        public void ClearTables()
        {
            var repo = new DisconnectedRepository();

            repo.ClearTables();
        }
Exemplo n.º 15
0
        public void UpdateLocalSetting(LocalSetting localSetting)
        {
            var repo = new DisconnectedRepository();

            repo.EditLocalSetting(localSetting);
        }
Exemplo n.º 16
0
        public void CreateLocalSetting(LocalSetting localSetting)
        {
            var repo = new DisconnectedRepository();

            repo.AddNewLocalSetting(localSetting);
        }
Exemplo n.º 17
0
 private void AddLogLine(LogLine logLine)
 {
     var repo  = new DisconnectedRepository();
     var files = repo.GetLogLines();
 }
Exemplo n.º 18
0
        public LocalSetting GetSettings()
        {
            var repo = new DisconnectedRepository();

            return(repo.GetLocalSettings());
        }