Exemplo n.º 1
0
 private void mnuLogViewer_Click(object sender, EventArgs e)
 {
     using (LogViewerForm f = new LogViewerForm())
     {
         f.ShowDialog();
     }
 }
Exemplo n.º 2
0
        private static void LoadLog(LogViewerForm pObjForm, string pStrLogPath)
        {
            pObjForm.grdContainer.BlockUI();

            try
            {
                IList <LogDTO> lLstObj = GetLog(pObjForm, pStrLogPath).OrderByDescending(x => x.Date).ToList();

                pObjForm.Dispatcher.Invoke((Action) delegate
                {
                    pObjForm.SetLog(lLstObj);
                });
            }
            catch (Exception lObjException)
            {
                pObjForm.grdContainer.UnblockUI();
                pObjForm.Dispatcher.Invoke((Action) delegate
                {
                    CustomMessageBox.Show("Error", lObjException.Message);
                });
            }
            finally
            {
                pObjForm.grdContainer.UnblockUI();
            }
        }
Exemplo n.º 3
0
        private static IList <LogDTO> GetLog(LogViewerForm pObjForm, string pStrLogPath)
        {
            IList <LogDTO> lLstObjLog = new List <LogDTO>();

            string[] lArrStrLines = File.ReadAllLines(pStrLogPath, Encoding.UTF8);
            LogDTO   lObjLogDTO   = new LogDTO();

            if (lArrStrLines.Length > 0)
            {
                int lIntMaxLogView   = GetMaxLoagView();
                int lIntCountLogView = lArrStrLines.Length > lIntMaxLogView ? lIntMaxLogView : lArrStrLines.Length;
                int lIntEndLogView   = lArrStrLines.Length - lIntCountLogView;
                int lIntIndex        = 1;

                for (int i = lArrStrLines.Length - 1; i >= lIntEndLogView; i--)
                {
                    pObjForm.grdContainer.SetWaitMessage(string.Format("Procesando {0} de {1}", lIntIndex, lIntCountLogView));
                    DateTime?lDtmDate = GetDate(lArrStrLines[i]);

                    if (lDtmDate != null)
                    {
                        lObjLogDTO = ParseToDTO(lArrStrLines[i]);
                        lLstObjLog.Add(lObjLogDTO);
                    }
                    else
                    {
                        lObjLogDTO.Message += string.Format(" {0}", lArrStrLines[i]);
                    }

                    lIntIndex++;
                }
            }

            return(lLstObjLog);
        }
Exemplo n.º 4
0
        public static bool?Show(string pStrTitle, string pStrLogPath, Window pFrmWindow)
        {
            LogViewerForm lObjForm = new LogViewerForm();

            try
            {
                Thread lObjThread = new Thread(() => LoadLog(lObjForm, pStrLogPath));
                lObjThread.Start();
            }
            catch (Exception lObjException)
            {
                CustomMessageBox.Show("Error", lObjException.Message);
            }

            lObjForm.tblTitle.Text = pStrTitle;
            lObjForm.Width         = 800;
            lObjForm.Height        = 600;
            lObjForm.Owner         = pFrmWindow;

            return(lObjForm.ShowDialog());
        }