public ReturnModel <bool> DeleteLog(StoredLogType logType, string id) { try { appLogWriter.Delete <AppLog>(x => x.LogId == SafeUtils.Guid(id) && x.LogType == (int)logType); return(new ReturnModel <bool>(true)); } catch (Exception ex) { log.Error(ex, "Error when getting Deleting App Log - id = " + id); return(new ReturnModel <bool>(ex)); } }
public Single Get() { var b0 = arr1[0]; var b1 = arr1[2]; var b2 = arr2[1]; var b3 = arr2[3]; var bytes = new byte[4]; bytes[0] = SafeUtils.XorByte(b0); bytes[1] = SafeUtils.XorByte(b1); bytes[2] = SafeUtils.XorByte(b2); bytes[3] = SafeUtils.XorByte(b3); return(BitConverter.ToSingle(bytes, 0)); }
public byte[] GetKey() { return(new byte[] { SafeUtils.XorByte(arr0[0]), SafeUtils.XorByte(arr0[2]), SafeUtils.XorByte(arr0[4]), SafeUtils.XorByte(arr0[6]), SafeUtils.XorByte(arr0[8]), SafeUtils.XorByte(arr0[10]), SafeUtils.XorByte(arr0[12]), SafeUtils.XorByte(arr0[14]), SafeUtils.XorByte(arr1[0]), SafeUtils.XorByte(arr1[2]), SafeUtils.XorByte(arr1[4]), SafeUtils.XorByte(arr1[6]), SafeUtils.XorByte(arr1[8]), SafeUtils.XorByte(arr1[10]), SafeUtils.XorByte(arr1[12]), SafeUtils.XorByte(arr1[14]), SafeUtils.XorByte(arr2[0]), SafeUtils.XorByte(arr2[2]), SafeUtils.XorByte(arr2[4]), SafeUtils.XorByte(arr2[6]), SafeUtils.XorByte(arr2[8]), SafeUtils.XorByte(arr2[10]), SafeUtils.XorByte(arr2[12]), SafeUtils.XorByte(arr2[14]), SafeUtils.XorByte(arr3[0]), SafeUtils.XorByte(arr3[2]), SafeUtils.XorByte(arr3[4]), SafeUtils.XorByte(arr3[6]), SafeUtils.XorByte(arr3[8]), SafeUtils.XorByte(arr3[10]), SafeUtils.XorByte(arr3[12]), SafeUtils.XorByte(arr3[14]), }); }
public void Set(int a) { var bytes = BitConverter.GetBytes(a); var b0 = bytes[0]; var b1 = bytes[1]; var b2 = bytes[2]; var b3 = bytes[3]; arr1[0] = SafeUtils.XorByte(b0); arr1[1] = SafeUtils.GetRandomByte(); arr1[2] = SafeUtils.XorByte(b1); arr1[3] = SafeUtils.GetRandomByte(); arr2[0] = SafeUtils.GetRandomByte(); arr2[1] = SafeUtils.XorByte(b2); arr2[2] = SafeUtils.GetRandomByte(); arr2[3] = SafeUtils.XorByte(b3); }
public void UpdateDataFromUI() { config.LogDebug = cbLogDebug.Checked; config.LogError = cbLogError.Checked; config.LogInfo = cbLogInfo.Checked; config.LogWarn = cbLogWarn.Checked; config.EmailServerSettings.FromEmail = txtFromEmail.Text.Trim(); config.EmailServerSettings.ToEmail = txtToEmail.Text.Trim(); config.EmailServerSettings.Server = txtEmailServerName.Text.Trim(); config.EmailServerSettings.Port = SafeUtils.Int(txtEmailPort.Text.Trim()); config.EmailServerSettings.UserName = txtEmailUsername.Text.Trim(); config.EmailServerSettings.Password = txtEmailPassword.Text.Trim(); config.EmailServerSettings.UseSSL = cbEmailUseSSL.Checked; config.EmailServerSettings.UseHtmlMail = cbUseHtmlMessage.Checked; config.EmailTemplateSettings.DefaultSubject = txtEmailTemplateSubject.Text; config.EmailTemplateSettings.DefaultTextBody = txtEmailTemplateBody.Text; config.EmailTemplateSettings.DefaultHtmlBody = txtEmailTemplateBody.Text; }
public ReturnModel <bool> DeleteLog(StoredLogType logType, string id) { try { using (var session = appLogProvider.OpenSession <AppLog>()) { //fixme: delete by 100 items at a time var items = session.Query().Where(x => x.LogId == SafeUtils.Guid(id) && x.LogType == (int)logType).ToArray(); session.Delete(items); } return(new ReturnModel <bool>(true)); } catch (Exception ex) { log.Error(ex, "Error when getting Deleting App Log - id = " + id); return(new ReturnModel <bool>(ex)); } }
private void btSendTestEmail_Click(object sender, EventArgs e) { try { EmailUtils.SendMail(txtFromEmail.Text.Trim(), txtToEmail.Text.Trim(), "Test email from MonitorR", cbUseHtmlMessage.Checked, cbUseHtmlMessage.Checked ? "<html><b>Test html email from MonitorR</b></html>" : "Test email from MonitorR", txtEmailServerName.Text.Trim(), SafeUtils.Int(txtEmailPort.Text.Trim()), txtEmailUsername.Text.Trim(), txtEmailPassword.Text.Trim(), cbEmailUseSSL.Checked, 10); MessageBox.Show($"Successfully sent the mail to {txtToEmail.Text}"); } catch (Exception ex) { log.Error(ex, $"Unable to send email to - {txtToEmail.Text}"); MessageBox.Show($"Unable to send email to - {txtToEmail.Text} \n\n Exception : \n" + ex.RecursivelyGetExceptionMessage()); } }
static AppLog GetAppLogFromLine(string fileName, string line, string extractionPattern, string extractionPatternForFileName) { AppLog log = new AppLog(); Match match; if (String.IsNullOrEmpty(extractionPattern)) { match = defaultLogExpression.Match(line); } else { Regex expression = new Regex(extractionPattern); match = expression.Match(line); } if (match.Success) { if (match.Groups["longdatetime"].Value.IsTrimmedStringNotNullOrEmpty()) { log.Longdate = SafeUtils.DateTime(match.Groups["longdatetime"].Value); } else if (match.Groups["shorttime"].Value.IsTrimmedStringNotNullOrEmpty()) { log.Longdate = SafeUtils.DateTime(match.Groups["shorttime"].Value); if (match.Groups["shortdate"].Value.IsTrimmedStringNotNullOrEmpty()) { var shortDate = DateTime.UtcNow; shortDate = SafeUtils.DateTime(match.Groups["shortdate"].Value); log.Longdate = log.Longdate.UpdateDatePart(shortDate.Date); } else { var shortFilename = Path.GetFileName(fileName); var expression = new Regex(extractionPatternForFileName); var fileNameMatch = expression.Match(shortFilename ?? ""); if ((fileNameMatch.Groups["year"].Value.IsTrimmedStringNotNullOrEmpty()) && (fileNameMatch.Groups["month"].Value.IsTrimmedStringNotNullOrEmpty()) && (fileNameMatch.Groups["day"].Value.IsTrimmedStringNotNullOrEmpty())) { log.Longdate = log.Longdate.UpdateDatePart(SafeUtils.Int(fileNameMatch.Groups["year"].Value), SafeUtils.Int(fileNameMatch.Groups["month"].Value), SafeUtils.Int(fileNameMatch.Groups["day"].Value)); } else { Console.WriteLine("Unable to get the Log Date for Line - " + line); } } } else { log.Longdate = DateTime.UtcNow; } if (match.Groups["loglevel"].Value.IsTrimmedStringNotNullOrEmpty()) { log.Severity = match.Groups["loglevel"].Value; } if (match.Groups["machine"].Value.IsTrimmedStringNotNullOrEmpty()) { log.MachineName = match.Groups["machine"].Value; } else { log.MachineName = Environment.MachineName; } if (SafeUtils.Int(match.Groups["processid"].Value) != 0) { log.ProcessId = SafeUtils.Int(match.Groups["processid"].Value); } if (SafeUtils.Int(match.Groups["threadid"].Value) != 0) { log.ThreadId = SafeUtils.Int(match.Groups["threadid"].Value); } if (match.Groups["function"].Value.IsTrimmedStringNotNullOrEmpty()) { log.CurrentFunction = match.Groups["function"].Value; } if (match.Groups["filename"].Value.IsTrimmedStringNotNullOrEmpty()) { log.CurrentSourceFilename = match.Groups["filename"].Value; } if (SafeUtils.Int(match.Groups["linenumber"].Value) != 0) { log.CurrentSourceLineNumber = SafeUtils.Int(match.Groups["linenumber"].Value); } if (match.Groups["tag"].Value.IsTrimmedStringNotNullOrEmpty()) { log.CurrentTag = match.Groups["tag"].Value; } if (match.Groups["user"].Value.IsTrimmedStringNotNullOrEmpty()) { log.UserIdentity = match.Groups["user"].Value; } if (match.Groups["ip"].Value.IsTrimmedStringNotNullOrEmpty()) { log.RemoteAddress = match.Groups["ip"].Value; } if (match.Groups["result"].Value.IsTrimmedStringNotNullOrEmpty()) { log.Result = match.Groups["result"].Value; } if (match.Groups["loglevel"].Value.IsTrimmedStringNotNullOrEmpty()) { log.ElapsedTime = SafeUtils.Double(match.Groups["elapsedtime"].Value); } if (match.Groups["message"].Value.IsTrimmedStringNotNullOrEmpty()) { log.Message = match.Groups["message"].Value; } if (match.Groups["log-id"].Value.IsTrimmedStringNotNullOrEmpty()) { log.LogId = SafeUtils.Guid(match.Groups["log-id"].Value); } if (match.Groups["log-type"].Value.IsTrimmedStringNotNullOrEmpty()) { log.LogType = SafeUtils.Int(match.Groups["LogType"].Value); } if (match.Groups["application-Id"].Value.IsTrimmedStringNotNullOrEmpty()) { log.ApplicationId = match.Groups["application-Id"].Value; } if (match.Groups["corelation-id"].Value.IsTrimmedStringNotNullOrEmpty()) { log.CorelationId = match.Groups["corelation-id"].Value; } if (match.Groups["receivedDateAsTicks"].Value.IsTrimmedStringNotNullOrEmpty()) { log.ReceivedDateAsTicks = SafeUtils.Long(match.Groups["receivedDateAsTicks"].Value); } if (match.Groups["longdate-as-ticks"].Value.IsTrimmedStringNotNullOrEmpty()) { log.LongdateAsTicks = SafeUtils.Long(match.Groups["longdate-as-ticks"].Value); } if (match.Groups["app"].Value.IsTrimmedStringNotNullOrEmpty()) { log.App = match.Groups["app"].Value; } if (match.Groups["module"].Value.IsTrimmedStringNotNullOrEmpty()) { log.Module = match.Groups["module"].Value; } if (match.Groups["result-code"].Value.IsTrimmedStringNotNullOrEmpty()) { log.ResultCode = SafeUtils.Int(match.Groups["result-code"].Value); } if (match.Groups["function-name"].Value.IsTrimmedStringNotNullOrEmpty()) { log.FunctionName = match.Groups["function-name"].Value; } if (match.Groups["start-time"].Value.IsTrimmedStringNotNullOrEmpty()) { log.StartTime = SafeUtils.DateTime(match.Groups["start-time"].Value); } if (match.Groups["result"].Value.IsTrimmedStringNotNullOrEmpty()) { log.Result = match.Groups["result"].Value; } if (match.Groups["request"].Value.IsTrimmedStringNotNullOrEmpty()) { log.Request = match.Groups["request"].Value; } if (match.Groups["response"].Value.IsTrimmedStringNotNullOrEmpty()) { log.Response = match.Groups["response"].Value; } } return(log); }
protected void PopulateFromConfigFile() { var configLocation = GetConfigFileLocation(); if (configLocation == null || configLocation.Trim() == string.Empty) { throw new Exception("Unable to find the Config location"); } var builder = new ConfigurationBuilder() .SetBasePath(Path.GetDirectoryName(configLocation)) .AddJsonFile(Path.GetFileName(configLocation), optional: false, reloadOnChange: true); var config = builder.Build(); var appSettings = config.GetSection("configuration:appSettings"); var frameworkLogSettings = config.GetSection("Logging"); PopulateFromConfigFile(appSettings, frameworkLogSettings, configLocation); if (DbSettings.MigrationNamespace.IsTrimmedStringNullOrEmpty()) { throw new Exception(ErrorConstants.MigrationNamespaceIsEmpty); } ServerPort = SafeUtils.Int(appSettings[Strings.Config.ServerPort], ServerPort); AppName = Path.GetFileNameWithoutExtension(this.GetType().GetTypeInfo().Assembly.Location); BatchSizeToIndex = SafeUtils.Int(appSettings[StringConstants.Config.BatchSizeToIndex], BatchSizeToIndex); EnablePushToMasterIndexServer = SafeUtils.Bool(appSettings[StringConstants.Config.EnablePushToMasterIndexServer], false); if (EnablePushToMasterIndexServer) { var masterIndexServerSettings = appSettings.GetSection(StringConstants.Config.MasterIndexStoreSettings); MasterIndexStoreSettings = new MasterIndexStoreSettings(masterIndexServerSettings); } this.IndexStoreType = SafeUtils.Enum <IndexStoreType>(appSettings[StringConstants.Config.IndexStoreType], IndexStoreType.None); if (IndexStoreType == IndexStoreType.Lucene) { var luceneSettings = appSettings.GetSection(StringConstants.Config.LuceneIndexStoreSettings); LuceneIndexStoreSettings = new LuceneIndexStoreSettings(luceneSettings, (str) => { if (str.IsTrimmedStringNotNullOrEmpty() && str.Contains(Strings.Config.ConfigPath)) { str = str.Replace(Strings.Config.ConfigPath, FileUtils.GetFileDirectory(configLocation)); str = Path.GetFullPath(new Uri(str).LocalPath); } return(str); }); if (Directory.Exists(LuceneIndexStoreSettings.AppLogIndexFolder) == false) { Directory.CreateDirectory(LuceneIndexStoreSettings.AppLogIndexFolder); } if (Directory.Exists(LuceneIndexStoreSettings.PerformanceLogIndexFolder) == false) { Directory.CreateDirectory(LuceneIndexStoreSettings.PerformanceLogIndexFolder); } } else if (IndexStoreType == IndexStoreType.Sqlite3 || IndexStoreType == IndexStoreType.SqlServer || IndexStoreType == IndexStoreType.Postgresql || IndexStoreType == IndexStoreType.MySql) { var configSettings = appSettings.GetSection(StringConstants.Config.SqlIndexStoreSettings); this.SqlIndexStoreSettings = new DbSettings(configSettings, (str) => { if (str.IsTrimmedStringNotNullOrEmpty() && str.Contains(Strings.Config.ConfigPath)) { str = str.Replace(Strings.Config.ConfigPath, FileUtils.GetFileDirectory(configLocation)); str = Path.GetFullPath(new Uri(str).LocalPath); } return(str); }); } else if (IndexStoreType == IndexStoreType.ElasticSearch) { var configSettings = appSettings.GetSection(StringConstants.Config.EmbbededElasticSearchIndexStoreSettings); this.ElasticSearchIndexStoreSettings = new ElasticSearchIndexStoreSettings(configSettings); } //else if (IndexStoreType == IndexStoreType.EmbbededElasticSearch) //{ // var configSettings = appSettings.GetSection("embeddedElasticSearchIndexStoreSettings"); // this.EmbeddedElasticSearchIndexStoreSettings = new EmbeddedElasticSearchIndexStoreSettings(configSettings, (str) => // { // if (str.IsTrimmedStringNotNullOrEmpty() && str.Contains(Strings.Config.ConfigPath)) // { // str = str.Replace(Strings.Config.ConfigPath, FileUtils.GetFileDirectory(configLocation)); // str = Path.GetFullPath(new Uri(str).LocalPath); // } // return str; // }); //} else if (IndexStoreType == IndexStoreType.RaptorDB) { var configSettings = appSettings.GetSection(StringConstants.Config.RaptorDBIndexStoreSettings); this.RaptorDBIndexStoreSettings = new RaptorDBIndexStoreSettings(configSettings, (str) => { if (str.IsTrimmedStringNotNullOrEmpty() && str.Contains(Strings.Config.ConfigPath)) { str = str.Replace(Strings.Config.ConfigPath, FileUtils.GetFileDirectory(configLocation)); str = Path.GetFullPath(new Uri(str).LocalPath); } return(str); }); } else if (IndexStoreType == IndexStoreType.MongoDB) { var configSettings = appSettings.GetSection("mongoDBIndexStoreSettings"); this.MongoDBIndexStoreSettings = new MongoDBIndexStoreSettings(configSettings); } else { throw new Exception("Index Store Type is not configured"); } }
public ReturnModel <bool> DeleteLog(StoredLogType logType, string id) { dbManager.Delete <AppLog>(x => x.LogType == (int)logType && x.LogId == SafeUtils.Guid(id)); return(ReturnModel <bool> .Success(true)); }
public void Init() { byte b00 = 0x76; byte b01 = 0x6C; byte b02 = 0x4A; byte b03 = 0x93; byte b04 = 0xF5; byte b05 = 0x2F; byte b06 = 0xAA; byte b07 = 0x36; byte b08 = 0x77; byte b09 = 0x46; byte b10 = 0xB9; byte b11 = 0x79; byte b12 = 0x58; byte b13 = 0x4A; byte b14 = 0xDA; byte b15 = 0xBA; byte b16 = 0x41; byte b17 = 0x13; byte b18 = 0x53; byte b19 = 0xEA; byte b20 = 0x31; byte b21 = 0x2B; byte b22 = 0x91; byte b23 = 0x96; byte b24 = 0x54; byte b25 = 0x95; byte b26 = 0x86; byte b27 = 0xB8; byte b28 = 0xBC; byte b29 = 0x0B; byte b30 = 0x0A; byte b31 = 0xBB; arr0[0] = SafeUtils.XorByte(b00); arr0[1] = SafeUtils.GetRandomByte(); arr0[2] = SafeUtils.XorByte(b01); arr0[3] = SafeUtils.GetRandomByte(); arr0[4] = SafeUtils.XorByte(b02); arr0[5] = SafeUtils.GetRandomByte(); arr0[6] = SafeUtils.XorByte(b03); arr0[7] = SafeUtils.GetRandomByte(); arr0[8] = SafeUtils.XorByte(b04); arr0[9] = SafeUtils.GetRandomByte(); arr0[10] = SafeUtils.XorByte(b05); arr0[11] = SafeUtils.GetRandomByte(); arr0[12] = SafeUtils.XorByte(b06); arr0[13] = SafeUtils.GetRandomByte(); arr0[14] = SafeUtils.XorByte(b07); arr0[15] = SafeUtils.GetRandomByte(); arr1[0] = SafeUtils.XorByte(b08); arr1[1] = SafeUtils.GetRandomByte(); arr1[2] = SafeUtils.XorByte(b09); arr1[3] = SafeUtils.GetRandomByte(); arr1[4] = SafeUtils.XorByte(b10); arr1[5] = SafeUtils.GetRandomByte(); arr1[6] = SafeUtils.XorByte(b11); arr1[7] = SafeUtils.GetRandomByte(); arr1[8] = SafeUtils.XorByte(b12); arr1[9] = SafeUtils.GetRandomByte(); arr1[10] = SafeUtils.XorByte(b13); arr1[11] = SafeUtils.GetRandomByte(); arr1[12] = SafeUtils.XorByte(b14); arr1[13] = SafeUtils.GetRandomByte(); arr1[14] = SafeUtils.XorByte(b15); arr1[15] = SafeUtils.GetRandomByte(); arr2[0] = SafeUtils.XorByte(b16); arr2[1] = SafeUtils.GetRandomByte(); arr2[2] = SafeUtils.XorByte(b17); arr2[3] = SafeUtils.GetRandomByte(); arr2[4] = SafeUtils.XorByte(b18); arr2[5] = SafeUtils.GetRandomByte(); arr2[6] = SafeUtils.XorByte(b19); arr2[7] = SafeUtils.GetRandomByte(); arr2[8] = SafeUtils.XorByte(b20); arr2[9] = SafeUtils.GetRandomByte(); arr2[10] = SafeUtils.XorByte(b21); arr2[11] = SafeUtils.GetRandomByte(); arr2[12] = SafeUtils.XorByte(b22); arr2[13] = SafeUtils.GetRandomByte(); arr2[14] = SafeUtils.XorByte(b23); arr2[15] = SafeUtils.GetRandomByte(); arr3[0] = SafeUtils.XorByte(b24); arr3[1] = SafeUtils.GetRandomByte(); arr3[2] = SafeUtils.XorByte(b25); arr3[3] = SafeUtils.GetRandomByte(); arr3[4] = SafeUtils.XorByte(b26); arr3[5] = SafeUtils.GetRandomByte(); arr3[6] = SafeUtils.XorByte(b27); arr3[7] = SafeUtils.GetRandomByte(); arr3[8] = SafeUtils.XorByte(b28); arr3[9] = SafeUtils.GetRandomByte(); arr3[10] = SafeUtils.XorByte(b29); arr3[11] = SafeUtils.GetRandomByte(); arr3[12] = SafeUtils.XorByte(b30); arr3[13] = SafeUtils.GetRandomByte(); arr3[14] = SafeUtils.XorByte(b31); arr3[15] = SafeUtils.GetRandomByte(); }
private bool IsValid() { if (txtFromEmail.Text.IsTrimmedStringNullOrEmpty()) { MessageBox.Show("From Email should not be empty"); return(false); } if (!ValidationUtils.IsEmailValid(txtFromEmail.Text.Trim())) { MessageBox.Show("From Email is not valid"); return(false); } if (txtToEmail.Text.IsTrimmedStringNullOrEmpty()) { MessageBox.Show("To Email should not be empty"); return(false); } if (!ValidationUtils.IsEmailValid(txtToEmail.Text.Trim())) { MessageBox.Show("To Email is not valid"); return(false); } if (txtEmailServerName.Text.IsTrimmedStringNullOrEmpty()) { MessageBox.Show("Email Server should not be empty"); return(false); } if (SafeUtils.Int(txtEmailPort.Text) == 0) { MessageBox.Show("Email Port should be greater than Zero"); return(false); } if (txtEmailUsername.Text.IsTrimmedStringNullOrEmpty()) { MessageBox.Show("Email Usename should not be empty"); return(false); } if (txtEmailPassword.Text.IsTrimmedStringNullOrEmpty()) { MessageBox.Show("Email Password should not be empty"); return(false); } if (txtEmailTemplateSubject.Text.IsTrimmedStringNullOrEmpty()) { MessageBox.Show("Email Template Subject should not be empty"); return(false); } if (txtEmailTemplateBody.Text.IsTrimmedStringNullOrEmpty()) { MessageBox.Show("Email Template Body should not be empty"); return(false); } return(true); }