Example #1
0
        /// <summary>
        /// write a LogItem in logItems table
        /// </summary>
        /// <param name="module">current module</param>
        /// <param name="description">the event log description</param>
        /// <param name="type">the event log type. default TracerItemType.Info</param>
        public static void Write(PigeonCms.Module module, string description, TracerItemType type)
        {
            if (module.UseLog == Utility.TristateBool.True ||
                (module.UseLog == Utility.TristateBool.NotSet && LogProvider.AppUseLog))
            {
                var item = new LogItem();
                var man = new LogItemsManager();

                item.ModuleId = module.Id;
                item.Type = type;
                try
                {
                    //sometimes throw NullReferenceException
                    item.UserHostAddress = HttpContext.Current.Request.UserHostAddress;
                }
                catch { }
                try
                {
                    //sometimes throw NullReferenceException
                    item.SessionId = HttpContext.Current.Session.SessionID;
                }
                catch { }
                //item.Url = HttpContext.Current.Request.RawUrl;    //parte finale
                item.Url = Utility.Html.GetTextPreview(HttpContext.Current.Request.Url.AbsoluteUri, 495, ""); //all url
                item.Description = Utility.Html.GetTextPreview(description, 495, "");

                man.Insert(item);
            }
        }
Example #2
0
    protected void Grid1_RowDataBound(object sender, GridViewRowEventArgs e)
    {
        if (e.Row.RowType == DataControlRowType.DataRow)
        {
            var item = new PigeonCms.LogItem();
            item = (PigeonCms.LogItem)e.Row.DataItem;

            Literal LitModule = (Literal)e.Row.FindControl("LitModule");
            LitModule.Text = item.ModuleFullName;

            Literal LitIp = (Literal)e.Row.FindControl("LitIp");
            LitIp.Text = item.UserHostAddress;

            Literal LitSessionId = (Literal)e.Row.FindControl("LitSessionId");
            LitSessionId.Text = item.SessionId;

            Literal LitUrl = (Literal)e.Row.FindControl("LitUrl");
            string path = Utility.Html.GetTextPreview(item.Url, 40, "");
            try
            {
                Uri url = new Uri(item.Url);
                path = Utility.Html.GetTextPreview(url.AbsolutePath, 40, "");
                if (item.Url.StartsWith("https://"))
                    LitUrl.Text += "https://...";
            }
            catch { }

            LitUrl.Text += path;

            Literal LitDescription = (Literal)e.Row.FindControl("LitDescription");
            LitDescription.Text = Utility.Html.GetTextPreview(item.Description, 120, "");

            var LnkSel = (LinkButton)e.Row.FindControl("LnkSel");
            switch (item.Type)
            {
                case TracerItemType.Debug:
                    LnkSel.Text = "<i class='fa fa-pgn_debug fa-fw'></i>";
                    break;
                case TracerItemType.Info:
                    LnkSel.Text = "<i class='fa fa-pgn_info fa-fw'></i>";
                    break;
                case TracerItemType.Warning:
                    LnkSel.Text = "<i class='fa fa-pgn_warning fa-fw'></i>";
                    break;
                case TracerItemType.Alert:
                    LnkSel.Text = "<i class='fa fa-pgn_alert fa-fw'></i>";
                    break;
                case TracerItemType.Error:
                    LnkSel.Text = "<i class='fa fa-pgn_error fa-fw'></i>";
                    break;
                default:
                    LnkSel.Text = "<i class='fa fa-pgn_debug fa-fw'></i>";
                    break;
            }
        }
    }