LogEvent() public static method

public static LogEvent ( string Event ) : void
Event string
return void
Esempio n. 1
0
        private void CheckForCommonIssues()
        {
            // Confirm that we do not have NWNX4 files in the root directory.
            string[] xpFiles = Directory.GetFiles(NWN2InstallPath, "xp_*.dll");
            if (xpFiles.Length > 0)
            {
                // Report the warning.
                Program.LogEvent("WARNING: NWNX plugin files were found in the NWN2 install directory. These files are being moved to the a backup folder.");

                // Ensure that the backup directory exists.
                string BackupDirectory = NWN2InstallPath + "\\backup\\";
                if (!Directory.Exists(BackupDirectory))
                {
                    Directory.CreateDirectory(BackupDirectory);
                }

                // Move files.
                foreach (string filename in xpFiles)
                {
                    string destination = BackupDirectory + filename.Remove(0, NWN2InstallPath.Length + 1);
                    Program.LogEvent(string.Format("Moving '{0}' to '{1}'", filename, destination));
                    File.Move(filename, destination);
                }
            }
        }
Esempio n. 2
0
        private void PatchModuleResourceXML()
        {
            string ModuleDLResourcePath = GetModuleFolder() + "\\moduledownloaderresources.xml";

            Program.LogEvent(string.Format("Patching '{0}'", "moduledownloaderresources.xml"));

            // Load the XML file.
            XDocument ModuleDLResource = XDocument.Load(ModuleDLResourcePath);

            // Find each resource and adjust values.
            List <XElement> elements = ModuleDLResource.Root.Elements().ToList();

            foreach (ADLResource resource in ADLResources)
            {
                // Find element.
                XElement element = null;
                foreach (XElement e in elements)
                {
                    if ((string)e.Attribute("name") == resource.name)
                    {
                        element = e;
                        break;
                    }
                }

                // TODO: Add an element if it doesn't exist.
                if (element == null)
                {
                    Program.LogEvent(string.Format("WARNING: Could not find resource: {0}", resource.name));
                    continue;
                }

                // Adjust data.
                element.SetAttributeValue("hash", resource.hash);
                element.SetAttributeValue("downloadHash", resource.downloadHash);
                element.SetAttributeValue("dlsize", resource.dlsize);
                element.SetAttributeValue("size", resource.size);
                element.SetAttributeValue("critical", resource.critical);
                element.SetAttributeValue("exclude", resource.exclude);
                element.SetAttributeValue("urlOverride", resource.urlOverride);
            }

            ModuleDLResource.Save(ModuleDLResourcePath);
        }
Esempio n. 3
0
        void ParseOutput_Recompile(object sender, DataReceivedEventArgs e)
        {
            if (e.Data == null)
            {
                return;
            }

            // Log errors or warnings to console.
            if (e.Data.ToLower().Contains("error:") || e.Data.ToLower().Contains("warning:"))
            {
                Program.LogEvent(string.Format(e.Data.Trim()));
            }

            // Log all output to the log file.
            StreamWriter log = File.AppendText("DeploymentTool_Recompile.log");

            log.WriteLine("{0}", e.Data.Trim());
            log.Close();
        }
Esempio n. 4
0
        public void Run()
        {
            // Check configuration.
            LoadConfiguration();

            // Commonly used variables.
            wcDownloader = new WebClient();
            ADLResources = new List <ADLResource>();

            // Run through update process.
            CheckForCommonIssues();
            DownloadLatestACR();
            PatchModuleResourceXML();
            RecompileModuleScripts();
            FetchExternalDependencies();
            AdjustModuleVariables();

            // Give completion feedback.
            Program.LogEvent("Update process complete.");
        }
Esempio n. 5
0
        private void DownloadLatestACR()
        {
            // Download the latest ACR patch.
            Program.LogEvent(string.Format("Downloading latest ACR patch..."));
            WebClient downloader = new WebClient();

            wcDownloader.DownloadFile(PatchURL, "patch.xml");

            // Load the patch document.
            XDocument PatchDoc = XDocument.Load("patch.xml");

            // Load servers.
            ServerList = PatchDoc.Root.Element("servers").Elements().ToDictionary(el => (int)el.Attribute("id"), el => (string)el.Attribute("url"));
            if (ServerList.Count == 0)
            {
                throw new Exception("No download servers found. Contact the technical administrator.");
            }
            Program.LogEvent(string.Format("Found {0} servers.", ServerList.Count));

            // Parse module dependency/ADL resoures.
            List <XElement> resources = PatchDoc.Root.Element("module_externs").Elements().ToList();

            for (int i = 0; i < resources.Count; i++)
            {
                ADLResources.Add(new ADLResource(resources[i]));
            }
            if (ADLResources.Count == 0)
            {
                throw new Exception("No resources found. Contact the technical administrator.");
            }
            Program.LogEvent(string.Format("Loaded {0} resource entries.", ADLResources.Count));

            // Update ADL resources.
            string DownloadFolder = GetHomeSubfolder("staging\\client");

            foreach (ADLResource resource in ADLResources)
            {
                resource.Update(NWN2HomePath, DownloadFolder, ServerList);
            }
        }
Esempio n. 6
0
        private void RecompileModuleScripts()
        {
            // Recompile all scripts in the module.
            string Command   = Program.ScriptCompilerFilename;
            string Arguments = "-e -v1.70 -o";

            Arguments += " -h \"" + NWN2HomePath + "\"";
            Arguments += " -n \"" + NWN2InstallPath + "\"";
            Arguments += " -m \"" + ModuleName + "\"";
            Arguments += " \"" + NWN2HomePath + "\\modules\\" + ModuleName + "\\*.nss\"";
            string WorkingDirectory = NWNX4Path;

            // Process information.
            ProcessStartInfo cmdStartInfo = new ProcessStartInfo();

            cmdStartInfo.WorkingDirectory       = WorkingDirectory;
            cmdStartInfo.FileName               = Command;
            cmdStartInfo.Arguments              = Arguments;
            cmdStartInfo.RedirectStandardOutput = true;
            cmdStartInfo.RedirectStandardError  = true;
            cmdStartInfo.RedirectStandardInput  = true;
            cmdStartInfo.UseShellExecute        = false;
            cmdStartInfo.CreateNoWindow         = true;

            // Create recompile process.
            Process cmdProcess = new Process();

            cmdProcess.StartInfo           = cmdStartInfo;
            cmdProcess.OutputDataReceived += ParseOutput_Recompile;
            cmdProcess.ErrorDataReceived  += ParseOutput_Recompile;
            cmdProcess.EnableRaisingEvents = true;

            // Begin processing.
            Program.LogEvent(string.Format("Recompiling '{0}'", NWN2HomePath + "\\modules\\" + ModuleName + "\\*.nss"));
            cmdProcess.Start();
            cmdProcess.BeginOutputReadLine();
            cmdProcess.BeginErrorReadLine();
            cmdProcess.WaitForExit();
            Program.LogEvent(string.Format("Recompile complete. Logs available in '{0}'.", "DeploymentTool_Recompile.log"));
        }
Esempio n. 7
0
        private void FetchExternalDependencies()
        {
            Program.LogEvent("Fetching external dependencies...");

            List <DependencyResource> Dependencies = new List <DependencyResource>();

            // Load the dependencies from the patch xml.
            XDocument PatchDoc = XDocument.Load("patch.xml");

            // Check for the files section.
            if (PatchDoc.Root.Element("files") == null)
            {
                Program.LogEvent("ERROR: Malformed patch file! Files section missing. Skipping dependency checking.");
                return;
            }

            List <XElement> elements = PatchDoc.Root.Element("files").Elements().ToList();

            for (int i = 0; i < elements.Count; i++)
            {
                Dependencies.Add(new DependencyResource(elements[i]));
            }

            if (ADLResources.Count == 0)
            {
                Program.LogEvent(string.Format("WARNING: No external dependency records found."));
                return;
            }

            Program.LogEvent(string.Format("Found {0} external dependencies.", ADLResources.Count));

            // Upgrade dependencies.
            string DownloadFolder = GetHomeSubfolder("staging\\client");

            foreach (DependencyResource dependency in Dependencies)
            {
                dependency.Update(this, DownloadFolder);
            }
        }