internal static void UPDATE_Local_Config_With_Central_Config(string WebPath, string LocalPath, string FileName) { if (string.IsNullOrEmpty(Central_Config_File_Web_Cache)) { File_Operation.DELETE_File(LocalPath); //remove old config file Wclient.DownloadFile(WebPath, LocalPath); //if match read local files } else { File_Operation.DELETE_File(LocalPath);//remove old config file File_Operation.APPEND_AllTXT(LocalPath, Central_Config_File_Web_Cache); } Error_Operation.Log_Error("GET_Central_Config_File()", "Updated " + FileName + " from " + WebPath + ". It was downloaded to " + LocalPath, "", Error_Operation.LogSeverity.Verbose, Error_Operation.EventID.SWELF_Central_Config_Changed);//log change if (File_Operation.CHECK_File_Encrypted(LocalPath) == false) { Crypto_Operation.Secure_File(LocalPath); } }
internal static void Log_Error(string MethodNameInCode, string Message, string StackDetails, LogSeverity LogSeverity, EventID eventID = 0) { if (Settings.Logging_Level_To_Report.ToLower() == "verbose") { Message = Message + " Stack_Info=" + StackDetails; } string msg = "DateTime=" + DateTime.Now.ToString(Settings.SWELF_Date_Time_Format) + " SourceComputer=" + Settings.ComputerName + " Severity=" + Severity_Levels[(int)LogSeverity] + " Error_MethodInCode=" + MethodNameInCode + " Error_Message=" + Message + "\n"; try//write ALL to local error log 1st { File_Operation.CHECK_File_Size(Settings.GET_ErrorLog_Location); File_Operation.APPEND_AllTXT(Settings.GET_ErrorLog_Location, msg); } catch (Exception e) { try { File_Operation.APPEND_AllTXT(Settings.SWELF_Log_File_Location + "\\" + Path.GetRandomFileName() + "_" + Settings.ErrorFile_FileName, msg); } catch (Exception ex) { msg += "\nAdditional_ERROR: " + ex.Message.ToString() + " " + Settings.SWELF_PROC_Name + " was unable to write this error to a local file on this system at " + Settings.GET_ErrorLog_Location; } } if (Logging_Level_To_Report <= (int)LogSeverity) { try//write to eventlog { WRITE_Errors_To_EventLog(MethodNameInCode, Message, LogSeverity, eventID); } catch (Exception exc) { msg += "\nAdditional_ERROR: " + exc.Message.ToString() + " " + Settings.SWELF_PROC_Name + " was unable to write this error to the event log on this system"; try { File_Operation.APPEND_AllTXT(Settings.SWELF_Log_File_Location + "\\" + Path.GetRandomFileName() + "_" + Settings.ErrorFile_FileName, msg); } catch (Exception execp) { msg += "\nAdditional_ERROR: " + execp.Message.ToString() + " " + Settings.SWELF_PROC_Name + " was unable to write this error to a local file on this system at " + Settings.GET_ErrorLog_Location; } } try// send eventlog to collector { Log_Network_Forwarder.SEND_SINGLE_LOG(msg); } catch (Exception p) { msg += "\nAdditional_ERROR: " + p.Message.ToString() + " " + Settings.SWELF_PROC_Name + " was unable to write error to Event Log"; try//write to eventlog { WRITE_Errors_To_EventLog(MethodNameInCode, Message, LogSeverity, eventID); } catch (Exception exc) { msg += "\nAdditional_ERROR: " + exc.Message.ToString() + " " + Settings.SWELF_PROC_Name + " was unable to write this error to the event log on this system"; try { File_Operation.APPEND_AllTXT(Settings.SWELF_Log_File_Location + "\\" + Path.GetRandomFileName() + "_" + Settings.ErrorFile_FileName, msg); } catch (Exception execp) { msg += "\nAdditional_ERROR: " + execp.Message.ToString() + " " + Settings.SWELF_PROC_Name + " was unable to write this error to a local file on this system at " + Settings.GET_ErrorLog_Location; } } } } Data_Store.ErrorsLog.Add(msg); }