AIMS_BD_IATI.DAL.Logger.WriteToDbAndFile C# (CSharp) Method

WriteToDbAndFile() public static method

public static WriteToDbAndFile ( dynamic ex, LogType type, string orgId = null, string IatiIdentifier = null, string message = null ) : void
ex dynamic
type LogType
orgId string
IatiIdentifier string
message string
return void
        public static void WriteToDbAndFile(dynamic ex, LogType type, string orgId = null, string IatiIdentifier = null, string message = null)
        {
            try
            {
                if (message == null) message = ex.Message;

                Log log = new Log();
                log.DateTime = DateTime.Now;
                log.OrgId = orgId;
                log.IatiIdentifier = IatiIdentifier;
                log.Message = message;
                log.LogType = type.GetHashCode();

                using (TextWriter writer = new StringWriter())
                {
                    try
                    {
                        new JsonSerializer().Serialize(new JsonTextWriter(writer), ex);
                        log.ExceptionObj = writer.ToString();
                    }
                    catch { }
                }

                new AimsDbIatiDAL().InsertLog(log);
            }
            catch { }
            finally
            {
                Write(type + " " + message);
            }
        }