static void Main(string[] args) { //生成容器创建器 ContainerBuilder containerBuilder = new ContainerBuilder(); //注册所需类型 containerBuilder.Register <Audit, IAudit>().AsPerLifetimeScope <IAudit>(); //创建容器 IContainer container = containerBuilder.Build <Container>(); //调用 using (ILifetimeScope lifetimeScope = container.BeginLifetimeScope()) { IAudit audit = lifetimeScope.Resolve <IAudit>(lifetimeScope); if (audit != null) { audit.Load(); audit.Save(); } IAudit audit1 = lifetimeScope.Resolve <IAudit>(lifetimeScope); if (audit1 != null) { audit1.Load(); audit1.Save(); } } Console.ReadLine(); }
public bool Connect(IAudit audit, string host, int port, string lu, ConnectionConfig config) { tn = new Telnet(this, audit, config); tn.UseSSL = mUseSSL; tn.trace.optionTraceAnsi = mDebug; tn.trace.optionTraceDS = mDebug; tn.trace.optionTraceDSN = mDebug; tn.trace.optionTraceEvent = mDebug; tn.trace.optionTraceNetworkData = mDebug; tn.telnetDataEvent += new TelnetDataDelegate(tn_telnetDataEvent); if (lu == null || lu.Length == 0) { tn.lus = null; } else { tn.lus = new System.Collections.ArrayList(); tn.lus.Add(lu); } tn.Connect(this, host, port); if (!tn.WaitForConnect()) { tn.Disconnect(); string text = tn.DisconnectReason; tn = null; throw new TNHostException("connect to " + host + " on port " + port + " failed", text, null); //return false; } tn.trace.WriteLine("--connected"); return(true); }
public PanxoraService(string rootURL, string apiKey, IAudit audit) { client = new RestClient(rootURL); APIKey = apiKey; this.audit = audit; }
public override async Task <int> SaveChangesAsync(CancellationToken cancellationToken = default(CancellationToken)) { var modifiedEntries = ChangeTracker.Entries() .Where(x => x.Entity is IAudit && (x.State == EntityState.Added || x.State == EntityState.Modified)); foreach (var entry in modifiedEntries) { IAudit entity = entry.Entity as IAudit; if (entity != null) { var identityId = UserManager.IsLoggin() ? UserManager.ActiveUserId : -1; /*Thread.CurrentPrincipal.Identity.Name;*/ DateTime now = DateTime.UtcNow; if (entry.State == EntityState.Added) { entity.CreatorUserId = identityId; entity.CreationTime = now; } else { base.Entry(entity).Property(x => x.CreatorUserId).IsModified = false; base.Entry(entity).Property(x => x.CreationTime).IsModified = false; } entity.ModifierUserId = identityId; entity.LastModTime = now; } } return(await base.SaveChangesAsync()); }
public IReadOnlyList <IAuditStep> CreateAllSteps(IAudit audit) { var stepOrder = 0; var steps = new List <IAuditStep> { new AuditStep { WizardPageType = WizardPageEnum.Requirements, StepOrder = stepOrder++ }, }; // Add the steps for each entity the audit has foreach (var entity in audit.Policy.Entities) { steps.AddRange(GetEntitySteps(entity, ref stepOrder)); } // Add the Final step steps.AddRange(new List <IAuditStep> { { new AuditStep { WizardPageType = WizardPageEnum.Final, StepOrder = stepOrder } } }); // Set the order of the steps and the audit id foreach (var step in steps) { step.AuditId = audit.Id; } return(steps); }
public Context(IAudit audit) { helper = new ReportHelper(); this.audit = audit; template = new NormalizedVelocityContext(); logger = new Logger(); }
private void updateDVh(IAudit model) { try { generateDVh(model); Type type = model.GetType(); string tableName = getTableName(type); AuditDvh dvh = findDV(tableName, model.id.ToString()); if (dvh == null) { dvh = new AuditDvh(tableName, model.id.ToString(), model.dv); db.DVHs.Add(dvh); } else { dvh.dv = model.dv; db.Entry(dvh).State = EntityState.Modified; } db.SaveChanges(); } catch (Exception ex) { Console.WriteLine(ex); } }
public override int SaveChanges() { var modifiedEntries = ChangeTracker.Entries() .Where(x => x.Entity is IAudit && (x.State == EntityState.Added || x.State == EntityState.Modified)); foreach (var entry in modifiedEntries) { IAudit entity = entry.Entity as IAudit; if (entity != null) { var identityId = 1; /*Thread.CurrentPrincipal.Identity.Name;*/ DateTime now = DateTime.UtcNow; if (entry.State == EntityState.Added) { entity.CreatorUserId = identityId; entity.CreationTime = now; } else { base.Entry(entity).Property(x => x.CreatorUserId).IsModified = false; base.Entry(entity).Property(x => x.CreationTime).IsModified = false; } entity.ModifierUserId = identityId; entity.LastModTime = now; } } return(base.SaveChanges()); }
public void Dump(IAudit stream) { int i; if (debugWithCoordinates) { stream.WriteLine("-----"); string tens = " ", singles = " "; // the quoted strings must be 3 spaces each, it gets lost in translation by codeplex... for (i = 0; i < _CX; i += 10) { tens += String.Format("{0,-10}", i / 10); singles += "0123456789"; } stream.WriteLine(tens.Substring(0, 2 + _CX)); stream.WriteLine(singles.Substring(0, 2 + _CX)); } for (i = 0; i < _CY; i++) { string line = GetText(0, i, _CX); if (debugWithCoordinates) { line = String.Format(" {0,02}{1}", i, line); } stream.WriteLine(line); } if (debugWithCoordinates) { stream.WriteLine("-----"); } }
public MongoRepository(IAudit audit) { this.audit = audit; Type classType = typeof(T); context = new MongoDataContext(); entities = context.MongoDatabase.GetCollection <T>(classType.Name); }
private static bool AuditException(IAudit audit, HttpContext httpContext, double elapsedMs, Exception ex) { AuditForErrorContext(audit, httpContext) .ForContext("Exception", ex.ToString()) .Write(ErrorMessageTemplate, httpContext.Request.Method, GetPath(httpContext), 500, elapsedMs); return(false); }
public static void ApplyStateChanges(this IContext context) { foreach (var entry in (context as DbContext).ChangeTracker.Entries <IAudit>()) { IAudit stateInfo = entry.Entity; entry.State = StateHelpers.ConvertState(stateInfo.State); } }
public IndexModel(ISmsService smsService, ICitizenService citizenService, ICitizenNotifier citizenNotifier, SmsOptions smsOptions, IAudit audit) { _smsService = smsService; _smsOptions = smsOptions; _audit = audit; _citizenService = citizenService; _citizenNotifier = citizenNotifier; }
internal CalcFacade(Item data, IDataRepository sqlExpress, IAudit audit, ICustomerParser exp_evaluate, IContext context, SQLiteConnection connection, FileLogger log) { Log = log; Connection = connection; Audit = audit; Calculator = exp_evaluate; Context = context; Data = data; SqlExpress = sqlExpress; }
public void LogResumedExecution(IAudit values) { var command = new AuditCommand { Type = values.AuditType, Audit = values as Audit }; Publish(Serializer.Serialize(command)); }
private static void InitAudit() { AuditInstance = new SerilogAzureEventHubsAuditClient( new SerilogAzureEventHubsAuditClientConfiguration { ConnectionString = LogicEnvironment.SerilogAzureEventHubConnectionString, EventSource = LogicEnvironment.SerilogAzureEventHubEventSource, EnrichFromLogContext = true, } ); }
private void Execute(object command, IAudit executor) { try { executor.Audit(command); } finally { _container.Release(executor); } }
public static T Audit <T>(this IAudit <T> target, string user = "******") { if (!target.CreatedAt.HasValue) { target.CreatedAt = DateTime.UtcNow; target.CreatedBy = user; } target.UpdatedAt = DateTime.UtcNow; target.UpdatedBy = user; return((T)target); }
public static void Audits <T>(this IEnumerable <T> collection, int userId, IAudit auditClass) where T : IAudit { if (collection.IsNotNull()) { foreach (var item in collection) { if (item.IsNotNull()) { item.Audit(userId, auditClass); } } } }
private void ApplyRules() { //Approach via @julielerman: http://bit.ly/123661P foreach (var entry in this.ChangeTracker.Entries().Where(e => e.Entity is IAudit && (e.State == EntityState.Added) || (e.State == EntityState.Modified))) { IAudit e = (IAudit)entry.Entity; if (entry.State == EntityState.Added) { e.CreatedOn = DateTime.Now; } e.ModifiedOn = DateTime.Now; } }
public Audit( ActionEvent action, IAudit audit) { Action = action; Type = audit.GetType().ToString(); Description = audit.ToAudit(); var now = DateTime.Now; Date = now.Date; Time = now.TimeOfDay; }
private static IAudit AuditForErrorContext(IAudit audit, HttpContext httpContext) { var request = httpContext.Request; var loggedHeaders = request.Headers .Where(h => HeaderWhitelist.Contains(h.Key)) .ToDictionary(h => h.Key, h => h.Value.ToString()); var result = audit .ForContext("RequestHeaders", loggedHeaders, captureObjectStructure: true) .ForContext("RequestHost", request.Host) .ForContext("RequestProtocol", request.Protocol); return(result); }
public void Dump(IAudit stream) { int i; stream.WriteLine("-----"); stream.WriteLine(" 0 1 2 3 4 5 6 7 "); stream.WriteLine(" 01234567890123456789012345678901234567890123456789012345678901234567890123456789"); for (i = 0; i < _CY; i++) { string line = GetText(0, i, _CX); string lr = "" + i + " "; stream.WriteLine(lr.Substring(0, 2) + " " + line); } stream.WriteLine("-----"); }
internal string PrepareString(IAudit audit, bool includeData) { StringBuilder sb = new StringBuilder(); sb.Append($"User: [{audit.UserName}]. "); sb.Append($"Ip: [{audit.IPAddress}]. "); sb.Append($"Area: [{audit.AreaAccessed}]. "); if (includeData) { sb.Append($"RequestData: [{audit.Data}]"); } return(sb.ToString()); }
public Person(string familyName, string givenName, DateTime?dateOfBirth, RegionInfo country, ICitation citation, IAudit audit) { this.FamilyName = familyName; this.GiveNames = new List <string>() { givenName }; this.DateOfBirth = dateOfBirth; this.Appointments = new List <TemporalRole>(); this.Country = country; Citation = citation; Audit = audit; this.Locations = new List <TemporalLocation>(); this.Hierarchy = new HashSet <TemporalChainOfCommand>(); }
/// <summary> /// Connects a Telnet object to the host using the parameters provided /// </summary> /// <param name="audit">IAudit interface to post debug/tracing to</param> /// <param name="host">host ip/name</param> /// <param name="port">port to use</param> /// <param name="lu">lu to use or empty string for host negotiated</param> /// <param name="config">configuration parameters</param> /// <returns></returns> public bool Connect(IAudit audit, string host, int port, string lu, ConnectionConfig config) { if (tn != null) { tn.CursorLocationChanged -= tn_CursorLocationChanged; } tn = new Telnet(this, audit, config); tn.Trace.optionTraceAnsi = debug; tn.Trace.optionTraceDS = debug; tn.Trace.optionTraceDSN = debug; tn.Trace.optionTraceEvent = debug; tn.Trace.optionTraceNetworkData = debug; tn.telnetDataEventOccurred += tn_DataEventReceived; tn.CursorLocationChanged += tn_CursorLocationChanged; if (lu == null || lu.Length == 0) { tn.Lus = null; } else { tn.Lus = new List <string>(); tn.Lus.Add(lu); } if (!string.IsNullOrEmpty(sourceIP)) { tn.Connect(this, host, port, sourceIP); } else { tn.Connect(this, host, port); } if (!tn.WaitForConnect()) { tn.Disconnect(); var text = tn.DisconnectReason; tn = null; throw new TNHostException("connect to " + host + " on port " + port + " failed", text, null); } tn.Trace.WriteLine("--connected"); return(true); }
public async Task <SaveResponse <IAudit> > SaveAsync(IAudit audit) { var saveResponse = new SaveResponse <IAudit>(); try { saveResponse = await _auditRepository.SaveAsync(audit); } catch (Exception ex) { Console.WriteLine(ex); saveResponse.AddError(ex); _logManager.LogError(ex, "Error saving audit"); } return(saveResponse); }
public void Modified(object modifiled, DateTime timestamp) { Guid currentId = this.CurrentUserId ?? Guid.Empty; if (currentId == Guid.Empty) { throw new InvalidOperationException("IAudit User not defined."); } // Step 1. IAudit IAudit audit = modifiled as IAudit; if (audit != null) { audit.UpdatedById = currentId; audit.Updated = timestamp; } }
protected AbstractOrganisation(string name, TemporalRole trole, RegionInfo country, long controlRange, long influenceRange, ICitation citation, IAudit audit) { this.Country = country; Citation = citation; Audit = audit; this.Name = $"{name} {Size}"; this.Purposes = new List <TemporalRole>() { trole }; this.ZoneOfControl = new SimpleZone(controlRange * trole.Role.ControlFactor, 1.0 / trole.Role.ControlFactor); this.ZoneOfInfluence = new SimpleZone(influenceRange * trole.Role.InfluenceFactor, 1.0 / trole.Role.InfluenceFactor); this.Personel = new List <TemporalRole>(); this.Locations = new List <TemporalLocation>(); this.Hierarchy = new HashSet <TemporalChainOfCommand>(); }
public bool Connect(IAudit audit, string host, int port, string lu, ConnectionConfig config) { tn = new Telnet(this, audit, config); tn.UseSSL = mUseSSL; tn.trace.optionTraceAnsi = mDebug; tn.trace.optionTraceDS = mDebug; tn.trace.optionTraceDSN = mDebug; tn.trace.optionTraceEvent = mDebug; tn.trace.optionTraceNetworkData = mDebug; tnDataDelegate = new TelnetDataDelegate(tn_telnetDataEvent); // CFC,Jr 8/2/2008 tn.telnetDataEvent += tnDataDelegate; if (lu == null || lu.Length == 0) { tn.lus = null; } else { tn.lus = new System.Collections.ArrayList(); tn.lus.Add(lu); } // Modified CFCJR Feb/29/2008 to allow for local IP endpoint if (!string.IsNullOrEmpty(_sourceIP)) { tn.Connect(this, host, port, _sourceIP); } else { tn.Connect(this, host, port); } if (!tn.WaitForConnect()) { tn.Disconnect(); string text = tn.DisconnectReason; tn = null; throw new TNHostException("connect to " + host + " on port " + port + " failed", text, null); //return false; } tn.trace.WriteLine("--connected"); return(true); }
public static IAudit AuditRecursive(this IAudit model, object userId, IAudit auditClass) { model.Audit(userId, auditClass); var propsWithAudit = model.GetType().GetProperties() .Where(_ => typeof(IAudit).IsAssignableFrom(_.PropertyType)); foreach (var item in propsWithAudit) { if (item.GetValue(model).IsNotNull()) { var propModel = item.GetValue(model) as IAudit; propModel.Audit(userId, auditClass); } } return(model); }
public bool validateDVh(IAudit model) { bool result = true; Type type = model.GetType(); string tableName = getTableName(type); model.dv = generateDVh(model); AuditDvh currentDv = findDV(tableName, model.id.ToString()); if (currentDv != null) { result = model.dv == currentDv.dv; } else { result = false; } return(result); }
public RentalOfferController(IAudit audit, IQueueWriter queueWriter) { _audit = audit; _queueWriter = queueWriter; }