/// <summary> /// GetCredentialByCredentialId method implementation /// </summary> public MFAUserCredential GetCredentialByCredentialId(MFAWebAuthNUser user, string credentialId) { try { List <MFAUserCredential> _creds = _mfacredusers.GetData(); return(_creds.FirstOrDefault(s => s.UserId.SequenceEqual(user.Id) && (HexaEncoding.GetHexStringFromByteArray(s.Descriptor.Id)).Equals(credentialId))); } catch (Exception ex) { DataLog.WriteEntry(ex.Message, System.Diagnostics.EventLogEntryType.Error, 5000); throw new Exception(ex.Message); } }
/// <summary> /// GetCredentialsByUser method implementation /// </summary> public List <MFAUserCredential> GetCredentialsByUser(MFAWebAuthNUser user) { try { List <MFAUserCredential> _creds = _mfacredusers.GetData(); return(_creds.Where(s => s.UserId.SequenceEqual(user.Id)).ToList()); } catch (Exception ex) { DataLog.WriteEntry(ex.Message, System.Diagnostics.EventLogEntryType.Error, 5000); throw new Exception(ex.Message); } }
private void UploadLogDataToCentralServer(DataLog logToAdd) { try { if (logToAdd.Data != String.Empty) { db.DataLogs.Add(logToAdd); } } catch (Exception ex) { Logging.LogEntry(ex); } }
public DataLog ToDataLog() { var dataLog = new DataLog() { TableName = TableName, ActionType = ActionType, ActionDateTime = DateTime.UtcNow, RecordId = JsonConvert.SerializeObject(KeyValues), OriginalValue = OldValues.Count == 0 ? null : JsonConvert.SerializeObject(OldValues), NewValue = NewValues.Count == 0 ? null : JsonConvert.SerializeObject(NewValues) }; return(dataLog); }
public static int Insert(DataLog item) { string sql = string.Format("INSERT INTO MDS_IMP_DATA_LOG(FID,TEST_PROJECT_ID,IMP_DATE_TIME,FULL_FLODERNAME,IMPROWSCOUNT,IMP_STATUS,ERROR_MSG,CREATED_BY,CREATION_DATE,LAST_UPDATED_BY,LAST_UPDATE_DATE,LAST_UPDATE_IP,VERSION,IMPFILENAME,OBJECT_TABLE,TYPENAME) "); sql += string.Format("VALUES('{0}','{1}',to_date('{2}','yyyy/mm/dd hh24:mi:ss'),'{3}','{4}','{5}','{6}','{7}',to_date('{8}','yyyy/mm/dd hh24:mi:ss'),'{9}',to_date('{10}','yyyy/mm/dd hh24:mi:ss'),'{11}',{12},'{13}','{14}','{15}')", item.FID, item.TestProjectID, item.ImpDateTime.ToString("yyyy/MM/dd HH:mm:ss"), item.FullFloderName, item.ImpRowsCount, item.ImpStatus, item.ErrorMsg, item.CreatedBy, item.CreationDate.ToString("yyyy/MM/dd HH:mm:ss"), item.LastUpdatedBy, item.LastUpdateDate.ToString("yyyy/MM/dd HH:mm:ss"), item.LastUpdateIp, item.Version, item.ImpFileName, item.ObjectTable, item.TypeName); return(OracleHelper.Excuse(sql)); }
/// <summary> /// RemoveUserKey method implementation /// </summary> public override bool RemoveUserKey(string upn) { try { List <MFAUserKeys> _lst = _mfakeysusers.GetData(); int res = _lst.RemoveAll(s => s.UserName.ToLower().Equals(upn.ToLower())); _mfakeysusers.SetData(_lst); return(res > 0); } catch (Exception ex) { DataLog.WriteEntry(ex.Message, System.Diagnostics.EventLogEntryType.Error, 5000); throw new Exception(ex.Message); } }
public static List <DataLog> getDistinctList(string projectID) { List <DataLog> result = new List <DataLog>(); string sql = string.Format("SELECT DISTINCT(typename), version,TEST_PROJECT_ID, OBJECT_TABLE FROM MDS_IMP_DATA_LOG WHERE TEST_PROJECT_ID='{0}'", projectID); DataSet ds = OracleHelper.Query(sql); foreach (DataRow dr in ds.Tables[0].Rows) { DataLog item = DataLog.Parse(dr); result.Add(item); } return(result); }
/// <summary> /// RemoveUserCredential method implementation /// </summary> public bool RemoveUserCredential(MFAWebAuthNUser user, string credentialId) { try { List <MFAUserCredential> _lst = _mfacredusers.GetData(); int res = _lst.RemoveAll(s => s.UserId.SequenceEqual(user.Id) && (HexaEncoding.GetHexStringFromByteArray(s.Descriptor.Id)).Equals(credentialId)); _mfacredusers.SetData(_lst); return(res > 0); } catch (Exception ex) { DataLog.WriteEntry(ex.Message, System.Diagnostics.EventLogEntryType.Error, 5000); throw new Exception(ex.Message); } }
public void Load() { using (var context = CreateMethodContext()) { // Create data log record and save var dataLog = new DataLog(); dataLog.LogName = "SampleLog"; context.SaveOne(dataLog); // Create queue record and save, then get its id var queue = new JobQueue(); queue.JobQueueName = "SampleQueue"; queue.Log = dataLog.ToKey(); context.SaveOne(queue, context.DataSet); var queueId = queue.Id; // Create sample record var sampleRecord = new SampleRecord(); sampleRecord.SampleName = "SampleName"; context.SaveOne(sampleRecord); // Create job record and save, then get its id var job = new Job(); job.Queue = queue.ToKey(); job.CollectionName = DataTypeInfo.GetOrCreate <SampleRecord>().GetCollectionName(); job.RecordId = sampleRecord.Id; job.MethodName = "SampleMethod"; context.SaveOne(job); var jobId = job.Id; // Load the records back var queueKey = queue.ToKey(); var loadedQueue = context.Load(queueKey); var jobKey = new JobKey { Id = jobId }; var loadedJob = context.Load(jobKey); // Check that TemporalId based key works correctly Assert.True(loadedJob.Queue.Value == loadedQueue.ToKey().Value); // Run the job // TODO - incomment when implemented // loadedJob.Run(); context.Log.Verify("Completed"); } }
/// <summary> /// HasStoredKey method implementation /// </summary> public override bool HasStoredKey(string upn) { bool result = false; try { List <MFAUserKeys> _lst = _mfakeysusers.GetData(); result = (_lst.FirstOrDefault(s => s.UserName.ToLower().Equals(upn.ToLower()) && (!string.IsNullOrEmpty(s.UserKey))) != null); } catch (Exception ex) { DataLog.WriteEntry(ex.Message, System.Diagnostics.EventLogEntryType.Error, 5000); throw new Exception(ex.Message); } return(result); }
public void Query(Action <WePorjectDbContext> actions) { var context = new WePorjectDbContext(); var log = new DataLog(); context.Database.Log = log.AddLog; var sw = new Stopwatch(); sw.Start(); actions(context); sw.Stop(); if (sw.ElapsedMilliseconds >= warnMilliseconds) { LogHelper.AddSqlLog($"[EF Query 2]警告({sw.ElapsedMilliseconds}ms):{actions.Target.GetType()}.{actions.Method.Name}\r\n{string.Join("", log.Logs)}"); } }
public void AddDataTest() { DateTime date = DateTime.UtcNow; DataLogger logger = new DataLogger("mongodb://WHS", "Test"); DataLog data = new DataLog() { Type = "TestData", Date = date, JsonData = "{ TestValue = Test}" }; DataLog dataGet = logger.AddData(data); List <DataLog> logs = logger.GetData("TestData", null, null); Assert.IsNotNull(logs); Assert.IsTrue(logs.Count > 0); }
/// <summary> /// AddCredential method implementation /// </summary> public bool AddUserCredential(MFAWebAuthNUser user, MFAUserCredential credential) { try { credential.UserId = user.Id; List <MFAUserCredential> _lst = _mfacredusers.GetData(); _lst.Add(credential); _mfacredusers.SetData(_lst); return(true); } catch (Exception ex) { DataLog.WriteEntry(ex.Message, System.Diagnostics.EventLogEntryType.Error, 5000); throw new Exception(ex.Message); } }
/// <summary> /// IsMFAUserRegistered method implementation /// </summary> private bool IsMFAUserRegistered(string upn) { try { if (string.IsNullOrEmpty(upn)) { return(false); } List <MFAUser> _lst = _mfausers.GetData(); return(_lst.FirstOrDefault(s => s.UPN.ToLower().Equals(upn.ToLower())) != null); } catch (Exception ex) { DataLog.WriteEntry(ex.Message, System.Diagnostics.EventLogEntryType.Error, 5000); return(false); } }
private void MainWindow_Load(object sender, EventArgs e) { ToolTip tooltip = new ToolTip(); tooltip.SetToolTip(buttonDirectory, "Выбор директории входящих файлов"); labelStatus.Text = program.config.status; Text += $" ({Application.ProductVersion})"; fillElementsData(); if (LastLaunch.Default.positionX > 0 && LastLaunch.Default.positionY > 0) { Location = new Point(LastLaunch.Default.positionX, LastLaunch.Default.positionY); } BSResults.DataSource = DataLog.Load(); }
private bool LogEliminacion(DetallesViaje item, int tipo) { bool flag = false; try { DataLog dataLog = new DataLog() { NAF_Id = base.Afiliado.nAF_Id, SAF_NombreUsuario = base.Afiliado.sAF_NombreUsuario, DtFecha_Trans = DateTime.Now.Date, STime_Trans = DateTime.Now.ToLongTimeString() }; if (tipo == 1) { dataLog.SCod_Trans = "ANOVE"; dataLog.SConcepto = string.Concat("Eliminación de Destino: País: ", item.País, " Fecha ", item.FechaInicio); } else { dataLog.SCod_Trans = "ANOVM"; dataLog.SConcepto = string.Concat("Modificación de Destino: País: ", item.País, " Fecha ", item.FechaInicio); } dataLog.SAF_IP = base.Afiliado.sIP; dataLog.SBanco = string.Concat("Salida: ", item.FechaInicio); dataLog.SCuenta_Origen = string.Concat("Notificación ID: ", item.NotificacionId); dataLog.SCuenta_Destino = string.Concat("Destino ID: ", item.DestinoId); dataLog.SMonto = string.Empty; dataLog.STipo_Tarjeta = string.Concat("Retorno: ", item.FechaFin); dataLog.SBeneficiario = string.Empty; dataLog.SCedula_Id_B = string.Empty; dataLog.SSerial_Chequera = string.Empty; dataLog.SCheques = string.Empty; dataLog.STitular = base.Afiliado.sCO_Nombres; dataLog.ICantidad = 0; dataLog.SReferencia = string.Empty; dataLog.SMotivo_Suspension = item.NotificacionId.ToString(); dataLog.SDir_Envio_Chequera = item.DestinoId.ToString(); flag = HelperGlobal.LogTransAdd(dataLog); } catch (IBException bException) { } return(flag); }
private bool LogFavorito(string tipoaf, string numins, string bc, string benef, string ced) { bool flag = false; try { DataLog dataLog = new DataLog() { NAF_Id = base.Afiliado.nAF_Id, SAF_NombreUsuario = (string.IsNullOrEmpty(base.Afiliado.sAF_NombreUsuario) ? string.Empty : base.Afiliado.sAF_NombreUsuario), DtFecha_Trans = DateTime.Now.Date, STime_Trans = DateTime.Now.ToLongTimeString() }; if (this._Accion == EnumAccionAddUpdateAfiliadoFavoritos.Insert) { dataLog.SCod_Trans = "AFBCA"; dataLog.SConcepto = string.Concat("Afiliación de Favorito: Tipo Favorito: ", tipoaf, " Instrumento ", numins); } else { dataLog.SCod_Trans = "AFBCM"; dataLog.SConcepto = string.Concat("Modificación de Favorito: Tipo Favorito: ", tipoaf, " Instrumento ", numins); } dataLog.SAF_IP = (string.IsNullOrEmpty(base.Afiliado.sIP) ? string.Empty : base.Afiliado.sIP); dataLog.SBanco = (string.IsNullOrEmpty(bc) ? string.Empty : bc); dataLog.SCuenta_Origen = string.Empty; dataLog.SCuenta_Destino = string.Empty; dataLog.SMonto = string.Empty; dataLog.STipo_Tarjeta = string.Empty; dataLog.SBeneficiario = (string.IsNullOrEmpty(benef) ? string.Empty : benef); dataLog.SCedula_Id_B = (string.IsNullOrEmpty(ced) ? string.Empty : ced); dataLog.SSerial_Chequera = string.Empty; dataLog.SCheques = string.Empty; dataLog.STitular = (string.IsNullOrEmpty(base.Afiliado.sCO_Nombres) ? string.Empty : base.Afiliado.sCO_Nombres); dataLog.ICantidad = 0; dataLog.SReferencia = string.Empty; dataLog.SMotivo_Suspension = string.Empty; dataLog.SDir_Envio_Chequera = string.Empty; flag = HelperGlobal.LogTransAdd(dataLog); } catch (IBException bException) { } return(flag); }
private bool LogEliminacion(FavoritosAfiliado item, int tipo) { bool flag = false; try { DataLog dataLog = new DataLog() { NAF_Id = base.Afiliado.nAF_Id, SAF_NombreUsuario = base.Afiliado.sAF_NombreUsuario, DtFecha_Trans = DateTime.Now.Date, STime_Trans = DateTime.Now.ToLongTimeString() }; if (tipo == 1) { dataLog.SCod_Trans = "AFBCE"; dataLog.SConcepto = string.Concat("Eliminación de Favorito: Tipo Favorito: ", item.TipoDescripcion, " Instrumento ", item.NumeroInstrumento); } else { dataLog.SCod_Trans = "AFBCM"; dataLog.SConcepto = string.Concat("Modificación de Favorito: Tipo Favorito: ", item.TipoDescripcion, " Instrumento ", item.NumeroInstrumento); } dataLog.SAF_IP = base.Afiliado.sIP; dataLog.SBanco = string.Empty; dataLog.SCuenta_Origen = string.Empty; dataLog.SCuenta_Destino = string.Empty; dataLog.SMonto = string.Empty; dataLog.STipo_Tarjeta = string.Empty; dataLog.SBeneficiario = item.Beneficiario; dataLog.SCedula_Id_B = string.Empty; dataLog.SSerial_Chequera = string.Empty; dataLog.SCheques = string.Empty; dataLog.STitular = base.Afiliado.sCO_Nombres; dataLog.ICantidad = 0; dataLog.SReferencia = string.Empty; dataLog.SMotivo_Suspension = string.Empty; dataLog.SDir_Envio_Chequera = string.Empty; flag = HelperGlobal.LogTransAdd(dataLog); } catch (IBException bException) { } return(flag); }
private string LogExtraEfectivo() { //HelperEnvioCorreo.BuscarCamposCorreo(base.sCod, base.Afiliado.sCO_Nombres, base.Afiliado.CO_Email, new decimal(0), string.Empty, this._Notificacion.FechaInicio, string.Empty, string.Empty, string.Empty, this._Notificacion.PaisNombre, string.Empty, this._Notificacion.FechaFin, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty, string.Empty); //HelperEnvioCorreo.BuscarCamposCorreo(this.sCod, base.Afiliado.sCO_Nombres, base.Afiliado.CO_Email, montoSolic, (string.IsNullOrEmpty(this.CtaAcreditar) ? string.Empty : this.CtaAcreditar), (string.IsNullOrEmpty(this.CtaAcreditar) ? string.Empty : this.CtaAcreditar), this.mensaje, (string.IsNullOrEmpty("Mismo Titular en BAV") ? string.Empty : "Mismo Titular en BAV"), (string.IsNullOrEmpty(this.CtaAcreditar) ? string.Empty : this.CtaAcreditar), string.Empty, (string.IsNullOrEmpty(this.CtaDebitar) ? string.Empty : this.CtaDebitar), string.Empty, string.Empty, (string.IsNullOrEmpty("Extra Efectivo") ? string.Empty : "Extra Efectivo"), (string.IsNullOrEmpty(this.CtaDebitar) ? string.Empty : this.CtaDebitar), (string.IsNullOrEmpty(base.Afiliado.sCO_Nombres) ? string.Empty : base.Afiliado.sCO_Nombres), string.Empty, (string.IsNullOrEmpty(this.Email) ? string.Empty : this.Email)); string empty = string.Empty; DataLog dataLog = new DataLog() { NAF_Id = base.Afiliado.nAF_Id, SAF_NombreUsuario = base.Afiliado.sAF_NombreUsuario, DtFecha_Trans = DateTime.Now.Date, STime_Trans = DateTime.Now.ToLongTimeString(), SCod_Trans = this.SCod_Trans, SAF_IP = base.Afiliado.sIP, SBanco = string.Empty, SCuenta_Origen = this.CtaDebitar, SCuenta_Destino = this.CtaAcreditar, SMonto = Formatos.formatoMonto(montoSolic), STipo_Tarjeta = string.Empty, SBeneficiario = string.Empty, SCedula_Id_B = (string.IsNullOrEmpty(this.CedulaBeneficiario) ? string.Empty : this.CedulaBeneficiario), SSerial_Chequera = string.Empty, SCheques = string.Empty, STitular = base.Afiliado.sCO_Nombres, ICantidad = 0, SReferencia = this.mensaje, SConcepto = "Extra Efectivo", SMotivo_Suspension = string.Empty, SDir_Envio_Chequera = string.Empty }; try { HelperGlobal.LogTransAdd(dataLog); } catch (IBException bException) { empty = "Error al Grabar en LogTran"; } catch (Exception exception) { empty = "Error al Grabar en LogTran"; } return(empty); }
protected string LogSuspension(string result) { string empty = string.Empty; DataLog dataLog = new DataLog() { NAF_Id = base.Afiliado.nAF_Id, SAF_NombreUsuario = base.Afiliado.sAF_NombreUsuario, DtFecha_Trans = DateTime.Now.Date, STime_Trans = DateTime.Now.ToLongTimeString(), SAF_IP = base.Afiliado.sIP, SBanco = string.Empty, SCuenta_Origen = this.SNroCuenta, SCuenta_Destino = string.Empty, SMonto = this.Monto, STipo_Tarjeta = string.Empty, SBeneficiario = string.Empty, SCedula_Id_B = string.Empty, SSerial_Chequera = this.SerialChq, SCheques = string.Join(",", this.Cheques.ToArray()) }; if (dataLog.SCheques.Equals("0000")) { dataLog.SCod_Trans = "SUCHE"; } else { dataLog.SCod_Trans = "SUCHQ"; } dataLog.STitular = base.Afiliado.sCO_Nombres; dataLog.ICantidad = 0; dataLog.SReferencia = string.Empty; dataLog.SConcepto = string.Concat("Suspensión de Chequeras / Cheques: ", result); dataLog.SMotivo_Suspension = this.MotivoSusp; dataLog.SDir_Envio_Chequera = string.Empty; try { HelperGlobal.LogTransAdd(dataLog); } catch (IBException bException) { empty = "Error al Grabar en LogTran"; } return(empty); }
public T Query <T>(Func <WePorjectDbContext, T> func) { var context = new WePorjectDbContext(); var log = new DataLog(); context.Database.Log = log.AddLog; var sw = new Stopwatch(); sw.Start(); var result = func(context); sw.Stop(); if (sw.ElapsedMilliseconds >= warnMilliseconds) { LogHelper.AddSqlLog($"[EF Query 1]警告({sw.ElapsedMilliseconds}ms):{func.Target.GetType()}.{func.Method.Name}\r\n{string.Join("", log.Logs)}"); } return(result); }
static void Main(string[] args) { using (var ctx = new Context()) { CheckMigrations(ctx); //var lst = ctx.DataLogs.Where(x=>x.Id.ToString()== "6ae4f127-00ff-47ad-92f5-165543eb8f3c").ToList(); //if (!ctx.DataLogs.Any()) //{ DataLog log = new DataLog(); log.Type = "Event"; log.Remark = $"{DateTime.Now.ToString("s")}"; ctx.DataLogs.Add(log); ctx.SaveChanges(); // } var ss = JsonConvert.SerializeObject(ctx.DataLogs.ToList()); Console.WriteLine($"{ss}"); } Console.ReadKey(); }
public void Log <TState>(LogLevel logLevel, EventId eventId, TState state, Exception exception, Func <TState, Exception, string> formatter) { if (eventId.Id > 100) { return; } var message = formatter(state, exception); var logRecord = new DataLog { Level = logLevel, TimeStamp = DateTime.Now, Name = eventId.Name ?? string.Empty, Description = message, }; dataLogRepository?.Add(logRecord); }
/// <summary> /// DoUpdateUserKey method implementation /// </summary> private void DoUpdateUserKey(string upn, string secretkey) { try { List <MFAUserKeys> _lst = _mfakeysusers.GetData(); _lst.Where(s => s.UserName.ToLower().Equals(upn.ToLower())).ToList() .ForEach(s => { s.UserKey = secretkey; }); _mfakeysusers.SetData(_lst); } catch (Exception ex) { DataLog.WriteEntry(ex.Message, System.Diagnostics.EventLogEntryType.Error, 5000); throw new Exception(ex.Message); } return; }
protected string LogTransferenciasPagos() { string empty = string.Empty; DataLog dataLog = new DataLog() { NAF_Id = base.Afiliado.nAF_Id, SAF_NombreUsuario = base.Afiliado.sAF_NombreUsuario, DtFecha_Trans = DateTime.Now.Date, STime_Trans = DateTime.Now.ToLongTimeString(), SCod_Trans = this.SCod_Trans, SAF_IP = base.Afiliado.sIP, SBanco = (string.IsNullOrEmpty(this.NumBanco) ? string.Empty : this.NumBanco), SCuenta_Origen = this.CtaDebitar, SCuenta_Destino = this.CtaAcreditar, SMonto = Formatos.formatoMonto(this.Monto), STipo_Tarjeta = (string.IsNullOrEmpty(this.TipoTarj) ? string.Empty : this.TipoTarj), SBeneficiario = (string.IsNullOrEmpty(this.Beneficiario) ? string.Empty : this.Beneficiario), SCedula_Id_B = (string.IsNullOrEmpty(this.CedulaBeneficiario) ? string.Empty : this.CedulaBeneficiario), SSerial_Chequera = string.Empty, SCheques = string.Empty, STitular = base.Afiliado.sCO_Nombres, ICantidad = 0, SReferencia = this.mensaje, SConcepto = this.Concepto, SMotivo_Suspension = string.Empty, SDir_Envio_Chequera = string.Empty }; try { HelperGlobal.LogTransAdd(dataLog); } catch (IBException bException) { empty = "Error al Grabar en LogTran"; } catch (Exception exception) { empty = "Error al Grabar en LogTran"; } return(empty); }
protected string LogAvance() { string empty = string.Empty; DataLog dataLog = new DataLog() { NAF_Id = base.Afiliado.nAF_Id, SAF_NombreUsuario = base.Afiliado.sAF_NombreUsuario, DtFecha_Trans = DateTime.Now.Date, STime_Trans = DateTime.Now.ToLongTimeString(), SCod_Trans = "TAVEF", SAF_IP = (string.IsNullOrEmpty(base.Afiliado.sIP) ? string.Empty : base.Afiliado.sIP), SBanco = (string.IsNullOrEmpty(this.NumBanco) ? string.Empty : this.NumBanco), SCuenta_Origen = (string.IsNullOrEmpty(this.Tarjeta) ? string.Empty : this.Tarjeta), SCuenta_Destino = (string.IsNullOrEmpty(this.CuentaDestino) ? string.Empty : this.CuentaDestino), SMonto = this.Monto.ToString(), STipo_Tarjeta = (string.IsNullOrEmpty(this.TipoTarjeta) ? string.Empty : this.TipoTarjeta), SBeneficiario = (string.IsNullOrEmpty(this.Beneficiario) ? string.Empty : this.Beneficiario), SCedula_Id_B = (string.IsNullOrEmpty(this.CedulaBeneficiario) ? string.Empty : this.CedulaBeneficiario), SSerial_Chequera = string.Empty, SCheques = (string.IsNullOrEmpty(this.Tarjeta) ? string.Empty : this.Tarjeta), STitular = (string.IsNullOrEmpty(base.Afiliado.sCO_Nombres) ? string.Empty : base.Afiliado.sCO_Nombres), ICantidad = 0, SReferencia = (string.IsNullOrEmpty(this.Mensaje) ? string.Empty : this.Mensaje), SConcepto = string.Empty, SMotivo_Suspension = string.Empty, SDir_Envio_Chequera = string.Empty }; try { HelperGlobal.LogTransAdd(dataLog); } catch (IBException bException) { empty = "Error al Grabar en LogTran"; } catch (Exception exception) { empty = "Error al Grabar en LogTran"; } return(empty); }
/// <summary> /// GetUserKey method implementation /// </summary> public override string GetUserKey(string upn) { string result = string.Empty; try { List <MFAUserKeys> _lst = _mfakeysusers.GetData(); MFAUserKeys _itm = _lst.FirstOrDefault(s => s.UserName.ToLower().Equals(upn.ToLower()) && (!string.IsNullOrEmpty(s.UserKey))); if (_itm != null) { result = _itm.UserKey; } } catch (Exception ex) { DataLog.WriteEntry(ex.Message, System.Diagnostics.EventLogEntryType.Error, 5000); throw new Exception(ex.Message); } return(result); }
/// <summary> /// DoUpdateUserCertificate method implementation /// </summary> private void DoUpdateUserCertificate(string upn, X509Certificate2 cert) { try { List <MFAUserKeys> _lst = _mfakeysusers.GetData(); _lst.Where(s => s.UserName.ToLower().Equals(upn.ToLower())).ToList() .ForEach(s => { s.UserCertificate = Convert.ToBase64String(cert.Export(X509ContentType.Pfx, CheckSumEncoding.CheckSumAsString(upn))); cert.Reset(); }); _mfakeysusers.SetData(_lst); } catch (Exception ex) { DataLog.WriteEntry(ex.Message, System.Diagnostics.EventLogEntryType.Error, 5000); throw new Exception(ex.Message); } return; }
// private Vector3 GLastLoc; // private Vector3 BLastLoc; void Start() { dat = FindObjectOfType <DataLog>(); // invisiTrail = Invisible.GetComponent<TrailRenderer>(); redTrail = RedBrush.GetComponent <TrailRenderer>(); partBlue = BlueBrush.GetComponent <ParticleSystem>(); partGreen = GreenBrush.GetComponent <ParticleSystem>(); partBlue.Stop(); partGreen.Stop(); count = 0; RtransformLocations = new List <Vector3>(); RLastLoc = RedBrush.transform.position; // GLastLoc = GreenBrush.transform.position; // BLastLoc = BlueBrush.transform.position; rquat = RedBrush.transform.rotation; }
/// <summary> /// GetUserCertificate method implmentation /// </summary> public override X509Certificate2 GetUserCertificate(string upn, bool generatepassword = false) { string pass = string.Empty; if (generatepassword) { pass = Utilities.CheckSumAsString(upn); } string request = "SELECT CERTIFICATE FROM KEYS WHERE UPN=@UPN"; SqlConnection con = new SqlConnection(_connectionstring); SqlCommand sql = new SqlCommand(request, con); SqlParameter prm = new SqlParameter("@UPN", SqlDbType.VarChar); sql.Parameters.Add(prm); prm.Value = upn.ToLower(); con.Open(); try { SqlDataReader rd = sql.ExecuteReader(); if (rd.Read()) { string strcert = rd.GetString(0); return(new X509Certificate2(Convert.FromBase64String(strcert), pass, X509KeyStorageFlags.Exportable | X509KeyStorageFlags.PersistKeySet)); } else { return(null); } } catch (Exception ex) { DataLog.WriteEntry(ex.Message, System.Diagnostics.EventLogEntryType.Error, 5000); throw new Exception(ex.Message); } finally { con.Close(); } }
public int SaveDataLog(IDataLogDb dataLogDb, int? transactionNumber = null) { if (dataLogDb.InstanceId != _instanceId) throw new Exception("Attempt to save DataLog with wrong InstanceId"); DataLog record; var recordOld = new DataLog(); if (dataLogDb.DataLogId == 0) { record = new DataLog(); Context.AddToDataLogs(record); } else { record = Context.DataLogs.Where(r => r.DataLogId == dataLogDb.DataLogId).First(); ReflectionHelper.CopyAllProperties(record, recordOld); } record.InstanceId = _instanceId; record.UserId = dataLogDb.UserId; record.OperationTime = dataLogDb.OperationTime; record.TableName = dataLogDb.TableName; record.RecordId = dataLogDb.RecordId; record.Operation = dataLogDb.Operation; record.Details = dataLogDb.Details; record.TransactionNumber = dataLogDb.TransactionNumber; Context.SaveChanges(); if (dataLogDb.DataLogId == 0) { dataLogDb.DataLogId = record.DataLogId; LogToDb(UserId, "DataLogs", record.DataLogId, "I", XmlHelper.GetObjectXml(record), transactionNumber); } else { LogToDb(UserId, "DataLogs", record.DataLogId, "U", XmlHelper.GetDifferenceXml(recordOld, record), transactionNumber); } return dataLogDb.DataLogId; }
private void InsertLogToDb(int? instanceId, int userId, string tableName, int recordId, string operation, string details, int? transactionNumber) { var dataLog = new DataLog { InstanceId = instanceId, UserId = userId, OperationTime = DateTime.Now, TableName = tableName, RecordId = recordId, Operation = operation, Details = details, TransactionNumber = transactionNumber }; _context.AddToDataLogs(dataLog); _context.SaveChanges(); }
/// <summary> /// 向缓存中添加数据日志信息 /// </summary> /// <param name="dataLog">数据日志信息</param> public void AddDataLog(DataLog dataLog) { _dataLogs.Add(dataLog); }