コード例 #1
0
        protected override void LogInputHtml(string html, DebugHtmlType type)
        {
            lock (_lockDebugHtml)
            {
                try
                {
                    string currentPage = GetCurrentPageName();

                    if (string.IsNullOrEmpty(currentPage))
                    {
                        currentPage = "UnidentifiedPage";
                    }

                    string logFilename = String.Format("{0:yyyy-MM-dd-hh-mm-fffffff} ", DateTime.Now) + type + "_" + currentPage + ".txt";
                    byte[] bytes       = Encoding.ASCII.GetBytes(Html);

                    string value = TroubleshootingStore.Instance.GetValue("DebugHtml", currentPage);

                    if (string.IsNullOrEmpty(value))
                    {
                        TroubleshootingStore.Instance.AddValue(currentPage, "DebugHtml", currentPage, string.Empty, logFilename, bytes, false, _absoluteUri);
                    }
                    else
                    {
                        TroubleshootingStore.Instance.AddAttachment("DebugHtml", currentPage, logFilename, bytes, false, _absoluteUri);
                    }
                }
                catch (Exception ex)
                {
                    EventLog.WriteEntry("ListLogStatisticsWriter", ex.Message + Environment.NewLine + ex, EventLogEntryType.Warning);
                }
            }
        }
コード例 #2
0
        protected override void LogInputHtml(string html, DebugHtmlType type)
        {
            lock (_lockDebugHtml)
            {
                try
                {
                    SPSecurity.RunWithElevatedPrivileges(delegate
                    {
                        string logFilename = String.Format("{0:yyyy-MM-dd-hh-mm-fffffff} ", DateTime.Now) + type + "_" + GetCurrentPageName();
                        string path        = Path.Combine(_alphamosaikInstallationPath, @"logs\");

                        if (!Directory.Exists(path))
                        {
                            Directory.CreateDirectory(path);
                        }

                        var f7 = new FileInfo(path + logFilename);

                        if (!f7.Exists)
                        {
                            // Create a file to write to.
                            using (f7.CreateText())
                            {
                            }
                        }

                        using (StreamWriter swriterAppend = f7.AppendText())
                        {
                            swriterAppend.WriteLine(html);
                        }
                    });
                }
                catch (Exception ex)
                {
                    Utilities.LogException("Error in DebugHtml.LogInputHtml: " + ex.Message, ex,
                                           EventLogEntryType.Warning);
                }
            }
        }
コード例 #3
0
 protected abstract void LogInputHtml(string html, DebugHtmlType type);