Esempio n. 1
0
        protected virtual void LoadDo(ProgressCallback callback = null)
        {
            bool reportProgress = callback != null;
            var  files          = WorkDir.EnumerateFiles("*.tpac", SearchOption.TopDirectoryOnly).ToList();
            var  packageCount   = files.Count;
            int  i = 0;

            foreach (var file in files)
            {
                if (reportProgress)
                {
                    callback(i++, packageCount, file.Name, false);
                }
                var package = new AssetPackage(file.FullName);
                package.IsGuidLocked = true;
                _loadedPackages.Add(package);
                _packageLookup[package.Guid] = package;
                foreach (var assetItem in package.Items)
                {
                    _assetLookup[assetItem.Guid] = assetItem;
                    _loadedAssets.Add(assetItem);
                }
            }
            if (reportProgress)
            {
                callback(packageCount, packageCount, String.Empty, true);
            }
        }
        /**
         * initialize the script manager.
         */
        public override void init(ServletConfig config)

        {
            _config         = config;
            _servletContext = config.getServletContext();

            checkServletAPIVersion();

            string pwd       = new FilePath(_servletContext.getRealPath("/"));
            string webInfDir = new FilePath(_servletContext.getRealPath("/WEB-INF"));

            getQuercus().setPwd(pwd);
            getQuercus().setWebInfDir(webInfDir);

            // need to set these for non-Resin containers
            if (!CurrentTime.isTest() && !getQuercus().isResin())
            {
                Vfs.setPwd(pwd);
                WorkDir.setLocalWorkDir(webInfDir.lookup("work"));
            }

            initImpl(config);

            getQuercus().init();
            getQuercus().start();
        }
Esempio n. 3
0
        public async Task <Package> DownloadPackage(string packageName, bool?useFullNameOverride = null)
        {
            var depInfo = ResolvePackageName(packageName);

            var useFullName = Repo.Config.UseVersionedPackageFolders;
            var name        = depInfo.GetFullName();

            if (useFullNameOverride.HasValue)
            {
                useFullName = useFullNameOverride.Value;
            }

            await GetAndAddPackage(depInfo).ConfigureAwait(false);

            var package = Package.Factory.Open(Repo,
                                               Repo.Config.OperationMode == RepositoryOperationMode.Default
                    ? WorkDir.GetChildDirectoryWithName(useFullName ? name : depInfo.Name)
                    : WorkDir,
                                               name);

            await
            UpdateMultiple(package.GetNeededObjects(), new[] { package }, FindRemotesWithPackage(name).ToArray())
            .ConfigureAwait(false);

            return(package);
        }
Esempio n. 4
0
        public virtual RetCode DeleteFiles(string fieldName)
        {
            StringBuilder buf;
            string        fileName;
            RetCode       rc;

            rc = RetCode.Success;

            buf = new StringBuilder(Constants.BufSize);

            var propInfos = new List <PropertyInfo>();

            if (string.IsNullOrWhiteSpace(fieldName))
            {
                propInfos.AddRange(GetType().GetProperties().Where(pi => pi.Name.EndsWith("FileName")));
            }
            else
            {
                propInfos.Add(GetType().GetProperty(fieldName));
            }

            foreach (var pi in propInfos)
            {
                buf.Clear();

                fileName = pi.GetValue(this, null) as string;

                if (!string.IsNullOrWhiteSpace(fileName) && !fileName.Equals("NONE", StringComparison.OrdinalIgnoreCase))
                {
                    if (!string.IsNullOrWhiteSpace(WorkDir) && !WorkDir.Equals("NONE", StringComparison.OrdinalIgnoreCase))
                    {
                        buf.Append(Globals.Path.Combine(WorkDir, fileName));
                    }
                    else
                    {
                        buf.Append(fileName);
                    }

                    try
                    {
                        Globals.File.Delete(buf.ToString());
                    }
                    catch (Exception ex)
                    {
                        if (ex != null)
                        {
                            // do nothing
                        }
                    }
                }
            }

            return(rc);
        }
        public virtual void ProcessArgv(string[] args)
        {
            if (args == null)
            {
                // PrintError

                goto Cleanup;
            }

            for (var i = 0; i < args.Length; i++)
            {
                if (args[i].Equals("--workingDirectory", StringComparison.OrdinalIgnoreCase) || args[i].Equals("-wd", StringComparison.OrdinalIgnoreCase))
                {
                    if (++i < args.Length)
                    {
                        WorkDir = args[i].Trim();

                        var regex = new Regex(Constants.ValidWorkDirRegexPattern);

                        if (WorkDir.Equals("NONE", StringComparison.OrdinalIgnoreCase) || !regex.IsMatch(WorkDir))
                        {
                            WorkDir = Constants.DefaultWorkDir;
                        }
                    }
                }
                else if (args[i].Equals("--filePrefix", StringComparison.OrdinalIgnoreCase) || args[i].Equals("-fp", StringComparison.OrdinalIgnoreCase))
                {
                    if (++i < args.Length)
                    {
                        FilePrefix = args[i].Trim();
                    }
                }
                else if (args[i].Equals("--ignoreMutex", StringComparison.OrdinalIgnoreCase) || args[i].Equals("-im", StringComparison.OrdinalIgnoreCase))
                {
                    IgnoreMutex = true;
                }
                else if (args[i].Equals("--runGameEditor", StringComparison.OrdinalIgnoreCase) || args[i].Equals("-rge", StringComparison.OrdinalIgnoreCase))
                {
                    RunGameEditor = true;
                }
            }

Cleanup:

            ;
        }
Esempio n. 6
0
        async Task ResolveDependencies(List <string> list, List <string> list2, List <Package> packages,
                                       SpecificVersion depInfo, List <SpecificVersion> done, bool useFullName = false, bool noCheckout = false)
        {
            if (!noCheckout && list.Contains(depInfo.Name.ToLower()))
            {
                Repository.Log("Conflicting package, not resolving {0}", depInfo);
                return;
            }
            var name = depInfo.GetFullName();

            if (list2.Contains(name))
            {
                Repository.Log("Duplicate package, skipping {0}", name);
                return;
            }
            list2.Add(name);

            if (!done.Contains(depInfo))
            {
                await GetAndAddPackage(depInfo).ConfigureAwait(false);

                done.Add(depInfo);
            }

            var package = Package.Factory.Open(Repo,
                                               WorkDir.GetChildDirectoryWithName(useFullName ? name : depInfo.Name), name);

            list.Add(depInfo.Name);
            packages.Add(package);

            // TODO: Higher level policy can be overwritten by dependencies (e.g specified dependency contraints). We dont want this.
            foreach (var dep in package.MetaData.GetDependencies())
            {
                await
                ResolveDependencies(list, list2, packages, ResolvePackageName(dep.GetFullName()), done, useFullName,
                                    noCheckout).ConfigureAwait(false);
            }

            OrderPackageLast(list, packages, package);
        }
Esempio n. 7
0
            public void FixPath(int depth = 0)
            {
                WorkDir = (WorkDir.EndsWith("/") || WorkDir.EndsWith("\\")) ? WorkDir.Substring(0, WorkDir.Length - 1) : WorkDir;
                Path    = FullPath.Replace(WorkDir + "/", "").Replace(WorkDir + "\\", "");
                Replace = !isDir
                    ? (System.IO.Path.GetExtension(FullPath).ToLowerEnglish().EndsWith("html") ? ("/" + Path.Substring(0, Path.Length - System.IO.Path.GetExtension(FullPath).Length).Replace("\\", "/")) : ("/" + Path.Replace("\\", "/")))
                    : "/" + Path.Replace("\\", "/");

                string x = string.Empty;

                if (depth == 0)
                {
                    x = "./";
                }
                else if (depth > 0)
                {
                    for (int i = 0; i < depth; i++)
                    {
                        x += "../";
                    }
                }
                Path = x + Path.Replace("\\", "/") + (!isDir ? (!Path.EndsWith(System.IO.Path.GetExtension(FullPath)) ? System.IO.Path.GetExtension(FullPath) : "") : "/index.html");
            }
Esempio n. 8
0
        public override IEnumerable <Image> LoadImages()
        {
            var imagePaths            = GetAllImagePathsInFolder(WorkDir, LegalImageExtensions);
            var trueLabelsByImageName = !TagInfoAvailable ? null : ReadTrueLabels(WorkDir + (WorkDir.EndsWith(@"\") ? string.Empty : @"\") + MetaInfoFileName);

            foreach (var imagePath in imagePaths)
            {
                var fileName = imagePath.Split('\\').Last();
                var tagNames = trueLabelsByImageName != null && trueLabelsByImageName.ContainsKey(fileName)
                    ? trueLabelsByImageName[fileName].ToList()
                    : Enumerable.Empty <string>().ToList();

                if (TagFilterEnabled && TagInfoAvailable)
                {
                    tagNames = tagNames.Where(AllowedTagNames.Contains).ToList();

                    if (tagNames.Count == 0)
                    {
                        continue;
                    }
                }

                yield return(new Image
                {
                    Path = imagePath,
                    TagNames = tagNames
                });
            }
        }
Esempio n. 9
0
        public int Publish()
        {
            if (File.Exists(JsonFile))
            {
                Echo("正在读取包信息");
                PackageInfo pkg        = JsonConvert.DeserializeObject <PackageInfo>(File.ReadAllText(JsonFile));
                string      outputpath = Path.Combine(Path.GetTempPath(), Path.GetFileNameWithoutExtension(Path.GetTempFileName()) + ".tar.gz");
                Echo("包名", pkg.name);
                Echo("版本", pkg.version);
                Echo("作者", pkg.author);

                Stream     outStream  = File.Create(outputpath);
                Stream     gzoStream  = new GZipOutputStream(outStream);
                TarArchive tarArchive = TarArchive.CreateOutputTarArchive(gzoStream);

                tarArchive.RootPath = WorkDir.Replace('\\', '/');
                if (tarArchive.RootPath.EndsWith("/"))
                {
                    tarArchive.RootPath = tarArchive.RootPath.Remove(tarArchive.RootPath.Length - 1);
                }

                AddDirectoryFilesToTar(tarArchive, JsonFile);

                pkg.modules.ForEach(path => AddDirectoryFilesToTar(tarArchive, Path.Combine(WorkDir, path)));
                pkg.files.ForEach(path => AddDirectoryFilesToTar(tarArchive, Path.Combine(WorkDir, path)));

                tarArchive.Close();

                Echo("已写入临时文件", outputpath);
                string hash = GetMD5HashFromFile(outputpath);
                Echo("哈希值", hash);

                Echo("正在尝试推送到远程服务器", api);
                try
                {
                    RestClient  client  = null;
                    RestRequest request = null;
                    MakeRequest("/package/push", Method.POST, out client, out request);

                    request.AddParameter("hash", hash);
                    request.AddParameter("jsonfile", File.ReadAllText(JsonFile));

                    string docFile = Path.Combine(WorkDir, "README.md");
                    if (File.Exists(docFile))
                    {
                        request.AddParameter("doc", File.ReadAllText(docFile));
                    }
                    else
                    {
                        Echo("根目录下没有README.md, 跳过文档上传");
                    }

                    request.AddFile("package", outputpath);
                    IRestResponse response = client.Execute(request);

                    Echo(response.Content);
                }
                catch (Exception ex)
                {
                    Error("推送到远程服务器出了一些问题:");
                    Error(ex.Message);
                }
            }
            else
            {
                Error("npkg.json is not exist");
            }

            Done("Push 结束..");
            return(1);
        }
Esempio n. 10
0
        private void UpdateImageConfig(ImageV1 image)
        {
            var config         = image.config;
            var historyStrings = new List <string>();

            // do git labels before other labels, to enable users to overwrite them
            if (GitLabels.HasValue())
            {
                IDictionary <string, string> gitLabels = null;
                try
                {
                    gitLabels = Utils.GitLabels.GetLabels(GitLabels.Value(), GitLabelsPrefix.Value());
                }
                catch (Exception ex)
                {
                    _logger.LogWarning($"Failed to read git labels: {ex.Message}");
                }

                if (gitLabels != null)
                {
                    foreach (var l in gitLabels)
                    {
                        config.Labels        = config.Labels ?? new Dictionary <string, string>();
                        config.Labels[l.Key] = l.Value;
                        historyStrings.Add($"--gitLabels {l.Key}={l.Value}");
                    }
                }
            }

            foreach (var label in Label.Values)
            {
                config.Labels = config.Labels ?? new Dictionary <string, string>();
                var split = label.Split('=', 2);
                if (split.Length != 2)
                {
                    throw new Exception($"Invalid label {label}");
                }

                config.Labels[split[0]] = split[1];
                historyStrings.Add($"--label {split[0]}={split[1]}");
            }

            foreach (var var in Env.Values)
            {
                config.Env = config.Env ?? new List <string>();
                config.Env.Add(var);
                historyStrings.Add($"--env {var}");
            }

            if (WorkDir.HasValue())
            {
                config.WorkingDir = WorkDir.Value();
                historyStrings.Add($"--workdir {WorkDir.Value()}");
            }

            if (User.HasValue())
            {
                config.User = User.Value();
                historyStrings.Add($"--user {User.Value()}");
            }

            if (Cmd.HasValue())
            {
                config.Cmd = SplitCmd(Cmd.Value()).ToList();
                var cmdString = string.Join(", ", config.Cmd.Select(c => $"\"{c}\""));
                historyStrings.Add($"--cmd {cmdString}");
            }

            if (Entrypoint.HasValue())
            {
                config.Entrypoint = SplitCmd(Entrypoint.Value()).ToList();
                var epString = string.Join(", ", config.Entrypoint.Select(c => $"\"{c}\""));
                historyStrings.Add($"--entrypoint {epString}");
            }

            if (historyStrings.Any())
            {
                image.history.Add(ImageV1History.Create(string.Join(", ", historyStrings), true));
            }

            foreach (var h in historyStrings)
            {
                _logger.LogDebug(h);
            }
        }
Esempio n. 11
0
        protected virtual void LoadDo(ProgressCallback callback = null)
        {
            bool            reportProgress = callback != null;
            List <FileInfo> files          = null;

#if !NETSTANDARD1_3
            Thread thread = new Thread(() =>
            {
                try
                {
                    var fs = WorkDir.EnumerateFiles("*.tpac", SearchOption.AllDirectories).ToList();
                    files  = fs;
                }
                catch (ThreadAbortException)
                {
                }
            });
            thread.Name         = "Tpac Searcher";
            thread.IsBackground = true;
            thread.Start();
            while (true)
            {
                if (reportProgress && !callback(-1, -1, String.Empty, false))
                {
                    if (thread.ThreadState != ThreadState.Stopped)
                    {
                        thread.Abort();
                    }
                    InterruptLoading();
                    return;
                }
                if (files != null)
                {
                    break;
                }
                Thread.Sleep(100);
                Thread.Yield();
            }
#else
            files = WorkDir.EnumerateFiles("*.tpac", SearchOption.AllDirectories).ToList();
#endif

            var packageCount = files.Count;
            int i            = 0;
            foreach (var file in files)
            {
                if (reportProgress && !callback(i++, packageCount, file.Name, false))
                {
                    InterruptLoading();
                    return;
                }
                var package = new AssetPackage(file.FullName);
                package.IsGuidLocked = true;
                _loadedPackages.Add(package);
                _packageLookup[package.Guid] = package;
                foreach (var assetItem in package.Items)
                {
                    _assetLookup[assetItem.Guid] = assetItem;
                    _loadedAssets.Add(assetItem);
                }
            }

            if (reportProgress && !callback(packageCount, packageCount, String.Empty, true))
            {
                InterruptLoading();
                return;
            }
        }
Esempio n. 12
0
        static void Main(string[] args)
        {
            DateTime startTime = DateTime.Now;

            if (Permission.Elevated() == false)
            {
                Console.ReadKey();
                Environment.Exit(1);
            }

            if (WorkDir.Find(args) == false)
            {
                Console.ReadKey();
                Environment.Exit(1);
            }

            EnvVar environmentVariables;
            string jsonEnvironmentFile = args[0] + @"\environment.json";

            if (!(File.Exists(jsonEnvironmentFile)))
            {
                Console.WriteLine(@"Cannot find configuration file " + jsonEnvironmentFile);
                environmentVariables = new EnvVar(true);
                string JSONresult = JsonConvert.SerializeObject(environmentVariables, Formatting.Indented);
                using (var tw = new StreamWriter(jsonEnvironmentFile, false)) {
                    tw.WriteLine(JSONresult.ToString());
                    tw.Close();
                }
                Console.ReadKey();
                Environment.Exit(1);
            }

            using (StreamReader reader = File.OpenText(jsonEnvironmentFile)) {
                JsonSerializer serializer = new JsonSerializer();
                environmentVariables = (EnvVar)serializer.Deserialize(reader, typeof(EnvVar));
            }

            string firewallData = environmentVariables.DataDirectory + @"\" + environmentVariables.DataFile;

            if (!(File.Exists(firewallData)))
            {
                Console.WriteLine(@"Cannot find firewall data file " + firewallData);
                Console.ReadKey();
                Environment.Exit(1);
            }

            string firewallOldData = environmentVariables.DataDirectory + @"\" + environmentVariables.OldDataFile;

            if (!(File.Exists(firewallOldData)))
            {
                Console.WriteLine(@"Cannot find firewall old data file " + firewallOldData);
                Console.ReadKey();
                Environment.Exit(1);
            }

            string firewallDataCopy = environmentVariables.DataDirectory + @"\" + environmentVariables.DataFileCopy;

            System.Diagnostics.Process          process   = new System.Diagnostics.Process();
            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
            startInfo.WindowStyle            = System.Diagnostics.ProcessWindowStyle.Hidden;
            startInfo.UseShellExecute        = false;
            startInfo.RedirectStandardOutput = true;
            startInfo.FileName  = @"cmd.exe";
            startInfo.Arguments = @"/C copy /b """ + firewallData + @""" """ + firewallDataCopy + @"""";
            process.StartInfo   = startInfo;
            process.Start();
            Console.WriteLine(process.StandardOutput.ReadToEnd());
            process.WaitForExit();
            process.Close();

            string firewallOldDataCopy = environmentVariables.DataDirectory + @"\" + environmentVariables.OldDataFileCopy;

            System.Diagnostics.Process          process2   = new System.Diagnostics.Process();
            System.Diagnostics.ProcessStartInfo startInfo2 = new System.Diagnostics.ProcessStartInfo();
            startInfo2.WindowStyle            = System.Diagnostics.ProcessWindowStyle.Hidden;
            startInfo2.UseShellExecute        = false;
            startInfo2.RedirectStandardOutput = true;
            startInfo2.FileName  = @"cmd.exe";
            startInfo2.Arguments = @"/C copy /b """ + firewallOldData + @""" """ + firewallOldDataCopy + @"""";
            process2.StartInfo   = startInfo2;
            process2.Start();
            Console.WriteLine(process2.StandardOutput.ReadToEnd());
            process2.WaitForExit();
            process2.Close();

            List <string> unhandledLines = new List <string>();

            Regex           headerRegex = new Regex(HeaderPattern, RegexOptions.IgnoreCase);
            MatchCollection matchedHeader;

            Regex           dataRegex = new Regex(DataPattern, RegexOptions.IgnoreCase);
            MatchCollection matchedData;

            Dictionary <string, string> connection;
            Dictionary <string, Dictionary <string, string> > receivedAllowedConnections = new Dictionary <string, Dictionary <string, string> >();

            int headerCount  = 0;
            int logDataCount = 0;

            string[] lines = File.ReadAllLines(firewallDataCopy);
            foreach (string line in lines)
            {
                matchedHeader = headerRegex.Matches(line);
                if (!(matchedHeader.Count == 0))
                {
                    headerCount++;
                }
                else
                {
                    matchedData = dataRegex.Matches(line);
                    if (!(matchedData.Count == 0))
                    {
                        logDataCount++;
                        if (matchedData[0].Groups.Count == 18)
                        {
                            connection = new Dictionary <string, string>();
                            connection.Add(Raw, matchedData[0].Groups[0].Value);
                            connection.Add(DateStamp, matchedData[0].Groups[1].Value + @"T" + matchedData[0].Groups[2].Value + @".000");
                            connection.Add(Action, matchedData[0].Groups[3].Value);
                            connection.Add(Protocol, matchedData[0].Groups[4].Value);
                            connection.Add(SrcIp, matchedData[0].Groups[5].Value);
                            connection.Add(DstIp, matchedData[0].Groups[6].Value);
                            connection.Add(SrcPort, matchedData[0].Groups[7].Value);
                            connection.Add(DstPort, matchedData[0].Groups[8].Value);
                            connection.Add(Size, matchedData[0].Groups[9].Value);
                            connection.Add(TcpFlags, matchedData[0].Groups[11].Value);
                            connection.Add(TcpSyn, matchedData[0].Groups[11].Value);
                            connection.Add(TcpAck, matchedData[0].Groups[12].Value);
                            connection.Add(TcpWin, matchedData[0].Groups[13].Value);
                            connection.Add(IcmpType, matchedData[0].Groups[14].Value);
                            connection.Add(IcmpCode, matchedData[0].Groups[15].Value);
                            connection.Add(Info, matchedData[0].Groups[16].Value);
                            connection.Add(Path, matchedData[0].Groups[17].Value);
                            if (connection[Action].Equals(@"ALLOW", StringComparison.OrdinalIgnoreCase))
                            {
                                if (connection[Path].Equals(@"RECEIVE", StringComparison.OrdinalIgnoreCase))
                                {
                                    while (true)
                                    {
                                        if (receivedAllowedConnections.ContainsKey(connection[DateStamp]))
                                        {
                                            DateTime connectionDatetime = DateTime.Parse(connection[DateStamp].ToString()).AddMilliseconds(1);
                                            connection[DateStamp] = connectionDatetime.ToString(FormatDateStamp);
                                        }
                                        else
                                        {
                                            receivedAllowedConnections.Add(connection[DateStamp], connection);
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            unhandledLines.Add(line);
                        }
                    }
                    else
                    {
                        if (line.Length > 0)
                        {
                            unhandledLines.Add(line);
                        }
                    }
                }
            }

            string[] linesOld = File.ReadAllLines(firewallOldDataCopy);
            foreach (string line in linesOld)
            {
                matchedHeader = headerRegex.Matches(line);
                if (!(matchedHeader.Count == 0))
                {
                    headerCount++;
                }
                else
                {
                    matchedData = dataRegex.Matches(line);
                    if (!(matchedData.Count == 0))
                    {
                        logDataCount++;
                        if (matchedData[0].Groups.Count == 18)
                        {
                            connection = new Dictionary <string, string>();
                            connection.Add(Raw, matchedData[0].Groups[0].Value);
                            connection.Add(DateStamp, matchedData[0].Groups[1].Value + @"T" + matchedData[0].Groups[2].Value + @".000");
                            connection.Add(Action, matchedData[0].Groups[3].Value);
                            connection.Add(Protocol, matchedData[0].Groups[4].Value);
                            connection.Add(SrcIp, matchedData[0].Groups[5].Value);
                            connection.Add(DstIp, matchedData[0].Groups[6].Value);
                            connection.Add(SrcPort, matchedData[0].Groups[7].Value);
                            connection.Add(DstPort, matchedData[0].Groups[8].Value);
                            connection.Add(Size, matchedData[0].Groups[9].Value);
                            connection.Add(TcpFlags, matchedData[0].Groups[11].Value);
                            connection.Add(TcpSyn, matchedData[0].Groups[11].Value);
                            connection.Add(TcpAck, matchedData[0].Groups[12].Value);
                            connection.Add(TcpWin, matchedData[0].Groups[13].Value);
                            connection.Add(IcmpType, matchedData[0].Groups[14].Value);
                            connection.Add(IcmpCode, matchedData[0].Groups[15].Value);
                            connection.Add(Info, matchedData[0].Groups[16].Value);
                            connection.Add(Path, matchedData[0].Groups[17].Value);
                            if (connection[Action].Equals(@"ALLOW", StringComparison.OrdinalIgnoreCase))
                            {
                                if (connection[Path].Equals(@"RECEIVE", StringComparison.OrdinalIgnoreCase))
                                {
                                    while (true)
                                    {
                                        if (receivedAllowedConnections.ContainsKey(connection[DateStamp]))
                                        {
                                            DateTime connectionDatetime = DateTime.Parse(connection[DateStamp].ToString()).AddMilliseconds(1);
                                            connection[DateStamp] = connectionDatetime.ToString(FormatDateStamp);
                                        }
                                        else
                                        {
                                            receivedAllowedConnections.Add(connection[DateStamp], connection);
                                            break;
                                        }
                                    }
                                }
                            }
                        }
                        else
                        {
                            unhandledLines.Add(line);
                        }
                    }
                    else
                    {
                        if (line.Length > 0)
                        {
                            unhandledLines.Add(line);
                        }
                    }
                }
            }

            File.Delete(firewallDataCopy);
            File.Delete(firewallOldDataCopy);

            Dictionary <string, Dictionary <string, string> > sshConnections  = new Dictionary <string, Dictionary <string, string> >();
            Dictionary <string, Dictionary <string, string> > rdpConnections  = new Dictionary <string, Dictionary <string, string> >();
            Dictionary <string, Dictionary <string, string> > icmpConnections = new Dictionary <string, Dictionary <string, string> >();

            foreach (var outerPair in receivedAllowedConnections)
            {
                foreach (var innerPair in outerPair.Value)
                {
                    if (innerPair.Key.Equals(DstPort, StringComparison.OrdinalIgnoreCase))
                    {
                        if (innerPair.Value.Equals(@"22", StringComparison.OrdinalIgnoreCase))
                        {
                            sshConnections.Add(outerPair.Key, outerPair.Value);
                        }
                        if (innerPair.Value.Equals(@"3389", StringComparison.OrdinalIgnoreCase))
                        {
                            rdpConnections.Add(outerPair.Key, outerPair.Value);
                        }
                    }
                    if (innerPair.Key.Equals(Protocol, StringComparison.OrdinalIgnoreCase))
                    {
                        if (innerPair.Value.Equals(@"ICMP", StringComparison.OrdinalIgnoreCase))
                        {
                            icmpConnections.Add(outerPair.Key, outerPair.Value);
                        }
                    }
                }
            }

            foreach (var outerPair in receivedAllowedConnections)
            {
                string output = null;
                bool   first  = true;
                foreach (var innerPair in outerPair.Value)
                {
                    if (!(innerPair.Key.Equals(Raw, StringComparison.OrdinalIgnoreCase)))
                    {
                        if (first)
                        {
                            output = innerPair.Value;
                        }
                        else
                        {
                            output = output + " " + innerPair.Value;
                        }
                        first = false;
                    }
                    //Console.WriteLine(output);
                }
            }

            foreach (var outerPair in sshConnections)
            {
                string output = null;
                bool   first  = true;
                foreach (var innerPair in outerPair.Value)
                {
                    if (!(innerPair.Key.Equals(Raw, StringComparison.OrdinalIgnoreCase)))
                    {
                        if (first)
                        {
                            output = innerPair.Value;
                        }
                        else
                        {
                            output = output + " " + innerPair.Value;
                        }
                        first = false;
                    }
                }
                Console.WriteLine(output);
            }

            foreach (var outerPair in rdpConnections)
            {
                string output = null;
                bool   first  = true;
                foreach (var innerPair in outerPair.Value)
                {
                    if (!(innerPair.Key.Equals(Raw, StringComparison.OrdinalIgnoreCase)))
                    {
                        if (first)
                        {
                            output = innerPair.Value;
                        }
                        else
                        {
                            output = output + " " + innerPair.Value;
                        }
                        first = false;
                    }
                }
                Console.WriteLine(output);
            }

            foreach (var line in unhandledLines)
            {
                Console.WriteLine(line);
            }

            Console.WriteLine(@"File line count: " + (lines.Length + linesOld.Length));
            Console.WriteLine(@"Headers: " + headerCount);
            Console.WriteLine(@"Log entries: " + logDataCount);
            Console.WriteLine(@"Received/Allowed entries:" + receivedAllowedConnections.Count);
            Console.WriteLine(@"SSH entries: " + sshConnections.Count);
            Console.WriteLine(@"RDP entries: " + rdpConnections.Count);
            Console.WriteLine(@"ICMP entries: " + icmpConnections.Count);
            Console.WriteLine(@"Unhandled entries: " + unhandledLines.Count);
            Console.WriteLine(@"Process time: " + DateTime.Now.Subtract(startTime).ToString(@"hh\:mm\:ss\.fff"));
            Console.WriteLine(@"Press any key to exit.");
            Console.ReadKey();
        }