public void StartDebugLog(object target)
        {
            string result = "";

            try
            {
                uint num = 0u;
                result = Simulator.CreateScriptErrorFile(ref num);
                if (num != 0u)
                {
                    mLogXmlWriter = new CustomXmlWriter(num);
                    mLogXmlWriter.WriteStartDocument();
                    mLogXmlWriter.WriteElementString("VirtualArtisanDebugger", target.GetType().ToString());
                    string[] data = GameUtils.GetGenericString(GenericStringID.VersionData).Split(new char[] { '\n' });

                    string[] labels = GameUtils.GetGenericString(GenericStringID.VersionLabels).Split(new char[] { '\n' });
                    int      count  = (labels.Length > data.Length) ? data.Length : labels.Length;
                    for (int i = 0; i < count; i++)
                    {
                        if (labels[i] == "Game Version:")
                        {
                            mLogXmlWriter.WriteElementString("GameVersion", data[i]);
                        }
                        else if (labels[i] == "Build Version:")
                        {
                            mLogXmlWriter.WriteElementString("BuildVersion", data[i]);
                        }
                    }


                    IGameUtils gameUtils = (IGameUtils)AppDomain.CurrentDomain.GetData("GameUtils");
                    if (gameUtils != null)
                    {
                        ProductVersion productFlags = (ProductVersion)gameUtils.GetProductFlags();
                        mLogXmlWriter.WriteElementString("Installed", productFlags.ToString());
                    }
                    mLogXmlWriter.WriteStartElement("Assemblies");

                    Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
                    foreach (Assembly assembly in assemblies)
                    {
                        string shortName = assembly.FullName.Replace(", Culture=neutral", "");
                        mLogXmlWriter.WriteElementString("Assembly", shortName);
                    }

                    mLogXmlWriter.WriteEndElement();

                    mLogXmlWriter.FlushBufferToFile();
                    NotifyUserOfDebugging(result);
                }
            }
            catch (Exception ex)
            {
                EndDebugLog();
                string title = I18n.Localize(CommonTexts.DEBUG_CANNOT_START_LOGGER, "Virtual Artisan Debugger CANNOT be started");
                string text  = I18n.Localize(CommonTexts.DEBUG_CANNOT_CREATE_LOG_FILE, "Cannot create debug log");

                Message.Sender.ShowError(title, text, false, ex);
            }
        }
        private void WriteStringFile()
        {
            try
            {
                List<string> strings = localizer.GetCollectedStrings();
                //debugger.Debug(this, "writing strings to file - count: " + strings.Count);
                uint fileHandle = 0u;
                string result = Simulator.CreateScriptErrorFile(ref fileHandle);
                if (fileHandle != 0u)
                {
                    // The XmlWriter has methods to write anything
                    CustomXmlWriter xmlWriter = new CustomXmlWriter(fileHandle);
                    foreach (string key in strings)
                    {
                        xmlWriter.WriteToBuffer(key);
                        xmlWriter.WriteToBuffer(System.Environment.NewLine);
                    }
                    xmlWriter.FlushBufferToFile();

                    Simulator.CloseScriptErrorFile(fileHandle);

                }

            }
            catch (Exception ex)
            {
                Debugger debugger = new Debugger(this);
                debugger.DebugError(this, "String collector failed to write file", ex);
                debugger.EndDebugLog();
            }
        }
        private void WriteStringFile()
        {
            try
            {
                List <string> strings = localizer.GetCollectedStrings();
                //debugger.Debug(this, "writing strings to file - count: " + strings.Count);
                uint   fileHandle = 0u;
                string result     = Simulator.CreateScriptErrorFile(ref fileHandle);
                if (fileHandle != 0u)
                {
                    // The XmlWriter has methods to write anything
                    CustomXmlWriter xmlWriter = new CustomXmlWriter(fileHandle);
                    foreach (string key in strings)
                    {
                        xmlWriter.WriteToBuffer(key);
                        xmlWriter.WriteToBuffer(System.Environment.NewLine);
                    }
                    xmlWriter.FlushBufferToFile();

                    Simulator.CloseScriptErrorFile(fileHandle);
                }
            }
            catch (Exception ex)
            {
                Debugger debugger = new Debugger(this);
                debugger.DebugError(this, "String collector failed to write file", ex);
                debugger.EndDebugLog();
            }
        }
Exemple #4
0
        private void StartDebugLog(object target)
        {
            string result = "";

            try
            {
                uint num = 0u;
                result = Simulator.CreateScriptErrorFile(ref num);
                if (num != 0u)
                {
                    mLogXmlWriter = new CustomXmlWriter(num);
                    mLogXmlWriter.WriteStartDocument();
                    mLogXmlWriter.WriteElementString("VirtualArtisanDebugger", target.GetType().ToString());
                    string[] data = GameUtils.GetGenericString(GenericStringID.VersionData).Split(new char[] { '\n' });

                    string[] labels = GameUtils.GetGenericString(GenericStringID.VersionLabels).Split(new char[] { '\n' });
                    int      count  = (labels.Length > data.Length) ? data.Length : labels.Length;
                    for (int i = 0; i < count; i++)
                    {
                        if (labels[i] == "Game Version:")
                        {
                            mLogXmlWriter.WriteElementString("GameVersion", data[i]);
                        }
                        else if (labels[i] == "Build Version:")
                        {
                            mLogXmlWriter.WriteElementString("BuildVersion", data[i]);
                        }
                    }


                    IGameUtils gameUtils = (IGameUtils)AppDomain.CurrentDomain.GetData("GameUtils");
                    if (gameUtils != null)
                    {
                        ProductVersion productFlags = (ProductVersion)gameUtils.GetProductFlags();
                        mLogXmlWriter.WriteElementString("Installed", productFlags.ToString());
                    }
                    mLogXmlWriter.WriteStartElement("Assemblies");

                    Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
                    foreach (Assembly assembly in assemblies)
                    {
                        string shortName = assembly.FullName.Replace(", Culture=neutral", "");
                        mLogXmlWriter.WriteElementString("Assembly", shortName);
                    }

                    mLogXmlWriter.WriteEndElement();

                    mLogXmlWriter.FlushBufferToFile();
                }
            }
            catch (Exception ex)
            {
                EndDebugLog();
            }
        }
Exemple #5
0
 public void Debug(object sender, string msg)
 {
     try
     {
         if (mLogXmlWriter != null)
         {
             CustomXmlAttribute[] attributes = new CustomXmlAttribute[]
             {
                 new CustomXmlAttribute("Time", SimClock.CurrentTime().ToString()),
                 new CustomXmlAttribute("Sender", sender.GetType().Name),
                 new CustomXmlAttribute("Id", GetId(sender))
             };
             mLogXmlWriter.WriteElementString("Log", ScriptError.Escape(msg), attributes);
             mLogXmlWriter.FlushBufferToFile();
         }
     }
     catch (Exception ex)
     {
     }
 }
        public void StartDebugLog(object target)
        {
            string result = "";
            try
            {
                uint num = 0u;
                result = Simulator.CreateScriptErrorFile(ref num);
                if (num != 0u)
                {
                    mLogXmlWriter = new CustomXmlWriter(num);
                    mLogXmlWriter.WriteStartDocument();
                    mLogXmlWriter.WriteElementString("VirtualArtisanDebugger", target.GetType().ToString());
                    string[] data = GameUtils.GetGenericString(GenericStringID.VersionData).Split(new char[] { '\n' });

                    string[] labels = GameUtils.GetGenericString(GenericStringID.VersionLabels).Split(new char[] { '\n' });
                    int count = (labels.Length > data.Length) ? data.Length : labels.Length;
                    for (int i = 0; i < count; i++)
                    {
                        if (labels[i] == "Game Version:")
                        {
                            mLogXmlWriter.WriteElementString("GameVersion", data[i]);
                        }
                        else if (labels[i] == "Build Version:")
                        {
                            mLogXmlWriter.WriteElementString("BuildVersion", data[i]);
                        }
                    }

                    IGameUtils gameUtils = (IGameUtils)AppDomain.CurrentDomain.GetData("GameUtils");
                    if (gameUtils != null)
                    {
                        ProductVersion productFlags = (ProductVersion)gameUtils.GetProductFlags();
                        mLogXmlWriter.WriteElementString("Installed", productFlags.ToString());
                    }
                    mLogXmlWriter.WriteStartElement("Assemblies");

                    Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
                    foreach (Assembly assembly in assemblies)
                    {
                        string shortName = assembly.FullName.Replace(", Culture=neutral", "");
                        mLogXmlWriter.WriteElementString("Assembly", shortName);
                    }

                    mLogXmlWriter.WriteEndElement();

                    mLogXmlWriter.FlushBufferToFile();
                    NotifyUserOfDebugging(result);
                }
            }
            catch (Exception ex)
            {
                EndDebugLog();
                string title = I18n.Localize(CommonTexts.DEBUG_CANNOT_START_LOGGER, "Virtual Artisan Debugger CANNOT be started");
                string text = I18n.Localize(CommonTexts.DEBUG_CANNOT_CREATE_LOG_FILE, "Cannot create debug log");

                Message.Sender.ShowError(title, text, false, ex);
            }
        }
        private void StartDebugLog(object target)
        {
            string result = "";
            try
            {
                uint num = 0u;
                result = Simulator.CreateScriptErrorFile(ref num);
                if (num != 0u)
                {
                    mLogXmlWriter = new CustomXmlWriter(num);
                    mLogXmlWriter.WriteStartDocument();
                    mLogXmlWriter.WriteElementString("VirtualArtisanDebugger", target.GetType().ToString());
                    string[] data = GameUtils.GetGenericString(GenericStringID.VersionData).Split(new char[] { '\n' });

                    string[] labels = GameUtils.GetGenericString(GenericStringID.VersionLabels).Split(new char[] { '\n' });
                    int count = (labels.Length > data.Length) ? data.Length : labels.Length;
                    for (int i = 0; i < count; i++)
                    {
                        if (labels[i] == "Game Version:")
                        {
                            mLogXmlWriter.WriteElementString("GameVersion", data[i]);
                        }
                        else if (labels[i] == "Build Version:")
                        {
                            mLogXmlWriter.WriteElementString("BuildVersion", data[i]);
                        }
                    }

                    IGameUtils gameUtils = (IGameUtils)AppDomain.CurrentDomain.GetData("GameUtils");
                    if (gameUtils != null)
                    {
                        ProductVersion productFlags = (ProductVersion)gameUtils.GetProductFlags();
                        mLogXmlWriter.WriteElementString("Installed", productFlags.ToString());
                    }
                    mLogXmlWriter.WriteStartElement("Assemblies");

                    Assembly[] assemblies = AppDomain.CurrentDomain.GetAssemblies();
                    foreach (Assembly assembly in assemblies)
                    {
                        string shortName = assembly.FullName.Replace(", Culture=neutral", "");
                        mLogXmlWriter.WriteElementString("Assembly", shortName);
                    }

                    mLogXmlWriter.WriteEndElement();

                    mLogXmlWriter.FlushBufferToFile();
                }
            }
            catch (Exception ex)
            {
                EndDebugLog();
            }
        }