Example #1
0
 private void MainForm_Load(object sender, EventArgs e)
 {
     try
     {
         this.lblVersion.Text = "Version: " + System.Reflection.Assembly.GetExecutingAssembly().GetName().Version.ToString();
         this.lblStatus.Text  = "";
     }
     catch (Exception ex)
     {
         log.WriteLog("Error happened in Load event: " + ex.Message, ex.StackTrace);
         UIUtil.ShowError("Unexcepted Error happened: " + ex.Message, "Error");
         this.BeginInvoke(new MethodInvoker(this.Close));
     }
 }
Example #2
0
        static void Main()
        {
            LogFileWriter log = new LogFileWriter();

            try
            {
                if (DatabaseConnection.OpenConnections() == false)
                {
                    UIUtil.ShowError("Cannot open database connection.", "ImportData - Error", true);
                    return;
                }

                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);
                Application.Run(new MainForm());
            }
            catch (Exception ex)
            {
                log.WriteLog("Unexpected error happened in main: " + ex.Message, ex.StackTrace);
                UIUtil.ShowError("Unexpected error happened: " + ex.Message, "ImportData - Error", true);
            }
            finally
            {
                DatabaseConnection.CloseConnections();
            }
        }
Example #3
0
        public static bool OpenConnections()
        {
            try
            {
                connSysproDb = new SqlConnection();

                connSysproDb.ConnectionString = AppConfig.DB_CONNECTION;

                connSysproDb.Open();
            }
            catch (Exception sex)
            {
                Log.WriteLog("Error happened during openning syspro db" + sex.Message, sex.StackTrace);
                return(false);
            }

            return(true);
        }
Example #4
0
        public override Task ProcessRequest(IRequestContext context)
        {
            if (Disabled)
            {
                context.Log?.Log(LogType.Step, LogLevel.Detailed, () =>
                                 $"Custom log '{Name}' is disabled and will not log this request");

                return(_nextNode.ProcessRequest(context));
            }

            if (Methods != null && Methods.Length > 0 && !Methods.Any(m => string.Equals(m, context.Incoming.Method, StringComparison.OrdinalIgnoreCase)))
            {
                context.Log?.Log(LogType.Step, LogLevel.Detailed, () =>
                                 $"Custom log '{Name}' is not logging this request because {context.Incoming.Method} methods are not logged");

                return(_nextNode.ProcessRequest(context));
            }

            return(_nextNode.ProcessRequest(context)
                   .ContinueWith(t =>
            {
                if (StatusCodes != null && StatusCodes.Length > 0 && StatusCodes.All(s => s != context.Outgoing.StatusCode))
                {
                    context.Log?.Log(LogType.Step, LogLevel.Detailed, () =>
                                     $"Custom log '{Name}' is not logging this request because {context.Outgoing.StatusCode} statuses are not logged");
                    return;
                }

                var entries = new List <string>
                {
                    $"{DateTime.Now.ToString("HH:mm:ss.ffK")} Request from {context.Incoming.SourceAddress} to {context.Incoming.Method} {context.Incoming.Scheme}://{context.Incoming.DomainName}{context.Incoming.Path}{context.Incoming.Query.ToUriComponent()} resulted in {context.Outgoing.StatusCode} {context.Outgoing.ReasonPhrase}"
                };

                if (Detailed)
                {
                    if (context.Incoming.Headers == null || context.Incoming.Headers.Count == 0)
                    {
                        entries.Add("  No request headers");
                    }
                    else
                    {
                        entries.Add("  Request headers");

                        foreach (var incomingHeader in context.Incoming.Headers)
                        {
                            if (incomingHeader.Value == null || incomingHeader.Value.Length == 0)
                            {
                                entries.Add($"  <  {incomingHeader.Key}");
                            }
                            else
                            {
                                foreach (var headerValue in incomingHeader.Value)
                                {
                                    entries.Add($"  <  {incomingHeader.Key}: {headerValue}");
                                }
                            }
                        }
                    }

                    if (context.Outgoing.Headers == null || context.Outgoing.Headers.Count == 0)
                    {
                        entries.Add("  No response headers");
                    }
                    else
                    {
                        entries.Add("  Response headers");

                        foreach (var outgoingHeader in context.Outgoing.Headers)
                        {
                            if (outgoingHeader.Value == null || outgoingHeader.Value.Length == 0)
                            {
                                entries.Add($"  <  {outgoingHeader.Key}");
                            }
                            else
                            {
                                foreach (var headerValue in outgoingHeader.Value)
                                {
                                    entries.Add($"  <  {outgoingHeader.Key}: {headerValue}");
                                }
                            }
                        }
                    }
                }

                _fileWriter?.WriteLog(_key, entries);
            }));
        }
Example #5
0
 override public void OnDebugReport(string msg)
 {
     logFileWriter.WriteLog(msg, Log.LOG_LV_DEBUG);
 }