Esempio n. 1
0
        public void TestAuditLogRef()
        {
            const string TEST_PREFIX      = "test";
            const int    TEST_ENTRY_COUNT = 3;
            var          document         = new SrmDocument(SrmSettingsList.GetDefault());

            Assert.IsTrue(document.AuditLog.AuditLogEntries.IsRoot);
            Assert.AreEqual(0, AuditLogEntryRef.PROTOTYPE.ListChildrenOfParent(document).Count());
            AuditLogEntry headEntry = document.AuditLog.AuditLogEntries;

            for (int i = 0; i < TEST_ENTRY_COUNT; i++)
            {
                var auditLogEntry = AuditLogEntry.CreateTestOnlyEntry(DateTime.UtcNow, SrmDocument.DOCUMENT_TYPE.mixed, TEST_PREFIX + i);
                headEntry = auditLogEntry.ChangeParent(headEntry);
            }
            Assert.IsNotNull(headEntry);
            Assert.AreEqual(TEST_ENTRY_COUNT, headEntry.Count);
            document = document.ChangeAuditLog(headEntry);
            var auditLogRefs = AuditLogEntryRef.PROTOTYPE.ListChildrenOfParent(document).Cast <AuditLogEntryRef>().ToList();

            Assert.AreEqual(TEST_ENTRY_COUNT, auditLogRefs.Count);
            var extraLogEntry = AuditLogEntry
                                .CreateTestOnlyEntry(DateTime.UtcNow, SrmDocument.DOCUMENT_TYPE.mixed, "extra entry")
                                .ChangeParent(document.AuditLog.AuditLogEntries);
            var document2 = document.ChangeAuditLog(extraLogEntry);

            Assert.AreEqual(TEST_ENTRY_COUNT + 1, AuditLogEntryRef.PROTOTYPE.ListChildrenOfParent(document2).Count());
            foreach (var auditLogRef in auditLogRefs)
            {
                var entry1 = auditLogRef.FindAuditLogEntry(document);
                var entry2 = auditLogRef.FindAuditLogEntry(document2);
                Assert.AreEqual(entry1, entry2);
            }
        }
Esempio n. 2
0
        public static AuditLogEntry SetOneDayDate(this AuditLogEntry log, DateTime date)
        {
            log.StartDate    = log.EndDate = date.Date;
            log.AffectedDays = (DayOfWeekEnum)(Math.Pow(2, (int)date.DayOfWeek));

            return(log);
        }
Esempio n. 3
0
            public void AssertEquals(AuditLogEntry entry)
            {
                Assert.AreEqual(ExpectedUndoRedo, entry.UndoRedo);
                Assert.AreEqual(ExpectedSummary, entry.Summary);

                if (ExpectedAllInfo.Length != entry.AllInfo.Count)
                {
                    Assert.Fail("Expected: " +
                                string.Join(",\n", ExpectedAllInfo.Select(l => l.ToString())) +
                                "\nActual: " + string.Join(",\n", entry.AllInfo.Select(l => l.ToString())));
                }

                for (var i = 0; i < ExpectedAllInfo.Length; ++i)
                {
                    Assert.AreEqual(ExpectedAllInfo[i], entry.AllInfo[i]);
                }

                var expectedEmpty = string.IsNullOrEmpty(ExtraInfo);
                var actualEmpty   = string.IsNullOrEmpty(entry.ExtraInfo);

                if (!expectedEmpty && !actualEmpty)
                {
                    AssertEx.NoDiff(ExtraInfo, entry.ExtraInfo);
                }
                else if (!expectedEmpty || !actualEmpty)
                {
                    Assert.AreEqual(ExtraInfo, entry.ExtraInfo);
                }
            }
        public object Read(
            object data,
            string masterPassphrase,
            params KeyValuePair <string, string>[] parameters)
        {
            FormatVersionAttribute formatVersion = FormatVersionAttribute.GetAttributeFromType(this.GetType());

            DLoggerManager.Instance.Logger.Log(DFramework.Logging.Interfaces.LoggerMessageType.VerboseHigh | DFramework.Logging.Interfaces.LoggerMessageType.Information, "Writing Credential from JSON using serialiser '{0}'.", formatVersion);

            JObject       dataJSON               = (JObject)data;
            String        id                     = JSONHelpers.ReadString(dataJSON, "ID");
            String        glyphKey               = JSONHelpers.ReadString(dataJSON, "GlyphKey");
            String        glyphColour            = JSONHelpers.ReadString(dataJSON, "GlyphColour");
            String        name                   = JSONHelpers.ReadString(dataJSON, "Name");
            String        description            = JSONHelpers.ReadString(dataJSON, "Description");
            String        website                = JSONHelpers.ReadString(dataJSON, "Website");
            DateTime      createdAt              = JSONHelpers.ReadDateTime(dataJSON, "CreatedAt");
            DateTime      lastUpdatedAt          = JSONHelpers.ReadDateTime(dataJSON, "LastUpdatedAt");
            DateTime      passwordLastModifiedAt = JSONHelpers.ReadDateTime(dataJSON, "PasswordLastModifiedAt", createdAt);
            String        username               = JSONHelpers.ReadString(dataJSON, "Username");
            String        password               = JSONHelpers.ReadString(dataJSON, "Password");
            JArray        tagsArray              = JSONHelpers.ReadJArray(dataJSON, "Tags", true);;
            List <String> tags                   = new List <String>();

            foreach (JValue curValue in tagsArray)
            {
                tags.Add(curValue.Value <String>());
            }
            String notes = JSONHelpers.ReadString(dataJSON, "Notes");
            List <AuditLogEntry> auditLogEntriesList = new List <AuditLogEntry>();

            if (dataJSON.ContainsKey("AuditLogEntries"))
            {
                ISerialiser auditLogEntrySerialiser = FormatVersions.Instance.GetSerialiser(formatVersion.Version, typeof(AuditLogEntry));
                JArray      auditLogEntries         = JSONHelpers.ReadJArray(dataJSON, "AuditLogEntries", true);
                foreach (JObject curEntry in auditLogEntries)
                {
                    AuditLogEntry entry = (AuditLogEntry)auditLogEntrySerialiser.Read(curEntry, String.Empty);
                    auditLogEntriesList.Add(entry);
                }
                if (auditLogEntriesList.Count > 0)
                {
                    auditLogEntriesList = auditLogEntriesList.OrderByDescending(ale => ale.DateTime).ToList();
                }
            }
            return(new Credential(id,
                                  glyphKey,
                                  glyphColour,
                                  name,
                                  description,
                                  website,
                                  createdAt,
                                  lastUpdatedAt,
                                  passwordLastModifiedAt,
                                  username,
                                  password,
                                  tags.ToArray(),
                                  notes,
                                  auditLogEntriesList.ToArray()));
        }
Esempio n. 5
0
 public void OkDialog()
 {
     Entry = string.IsNullOrEmpty(logMessageTextBox.Text)
         ? AuditLogEntry.CreateUndocumentedChangeEntry()
         : AuditLogEntry.CreateSimpleEntry(MessageType.modified_outside_of_skyline, SrmDocument.DOCUMENT_TYPE.none, logMessageTextBox.Text);
     DialogResult = DialogResult.OK;
 }
Esempio n. 6
0
            // Adjust entry so that comparisons against the expected document type
            // don't fail if we expect 'none' and have 'proteomic' or vice versa
            // We do this in this rather complicated way since we don't want to add any special
            // to the equality members of LogMessage.
            private AuditLogEntry AdjustDocumentType(AuditLogEntry entry)
            {
                if (ExpectedUndoRedo.DocumentType != entry.UndoRedo.DocumentType)
                {
                    entry = entry.ChangeUndoRedo(
                        entry.UndoRedo.MessageInfo.ChangeDocumentType(GetNewDocType(ExpectedUndoRedo.DocumentType,
                                                                                    entry.UndoRedo.DocumentType)));
                }

                if (ExpectedSummary.DocumentType != entry.Summary.DocumentType)
                {
                    entry = entry.ChangeSummary(
                        entry.Summary.MessageInfo.ChangeDocumentType(GetNewDocType(ExpectedSummary.DocumentType,
                                                                                   entry.Summary.DocumentType)));
                }


                // We take care of the case where the length doesn't match later
                if (ExpectedAllInfo.Length == entry.AllInfo.Count)
                {
                    int index  = entry.InsertUndoRedoIntoAllInfo ? 1 : 0;
                    var actual = entry.AllInfo.Skip(index).ToArray();
                    for (var i = index; i < ExpectedAllInfo.Length; ++i)
                    {
                        if (ExpectedAllInfo[i].DocumentType != actual[i - index].DocumentType)
                        {
                            actual[i - index] = (DetailLogMessage)actual[i - index].ChangeDocumentType(GetNewDocType(ExpectedAllInfo[i].DocumentType,
                                                                                                                     actual[i - index].DocumentType));
                        }
                    }
                    entry = entry.ChangeAllInfo(actual);
                }

                return(entry);
            }
Esempio n. 7
0
    void CreateAuditLog(object sender, EventArgs e)
    {
        var changes = this.ObjectStateManager.GetObjectStateEntries(EntityState.Deleted | EntityState.Modified);

        if (!changes.Any())
        {
            return;
        }
        var auditDataList = new List <AuditLogEntry>();

        foreach (ObjectStateEntry stateEntryEntity in changes)
        {
            if (!stateEntryEntity.IsRelationship && stateEntryEntity.Entity != null && !(stateEntryEntity.Entity is AuditLogEntry))
            {
                var audit = new AuditLogEntry();
                auditDataList.Add(audit);
            }
        }
        if (auditDataList.Count > 0)
        {
            foreach (var audit in auditDataList)
            {
                this.AddToAuditLogEntries(audit);
            }
        }
    }
        public IHttpActionResult PutAuditLogEntry(int id, AuditLogEntry auditLogEntry)
        {
            if (!ModelState.IsValid)
            {
                return(BadRequest(ModelState));
            }

            if (id != auditLogEntry.Id)
            {
                return(BadRequest());
            }

            db.Entry(auditLogEntry).State = EntityState.Modified;

            try
            {
                db.SaveChanges();
            }
            catch (DbUpdateConcurrencyException)
            {
                if (!AuditLogEntryExists(id))
                {
                    return(NotFound());
                }
                else
                {
                    throw;
                }
            }

            return(StatusCode(HttpStatusCode.NoContent));
        }
Esempio n. 9
0
        public bool ShowGenerateDecoysDlg(IWin32Window owner = null)
        {
            using (var decoysDlg = new GenerateDecoysDlg(DocumentUI))
            {
                if (decoysDlg.ShowDialog(owner ?? SkylineWindow) == DialogResult.OK)
                {
                    var refinementSettings = new RefinementSettings {
                        NumberOfDecoys = decoysDlg.NumDecoys, DecoysMethod = decoysDlg.DecoysMethod
                    };
                    ModifyDocument(Resources.SkylineWindow_ShowGenerateDecoysDlg_Generate_Decoys, refinementSettings.GenerateDecoys,
                                   docPair =>
                    {
                        var plural = refinementSettings.NumberOfDecoys > 1;
                        return(AuditLogEntry.CreateSingleMessageEntry(new MessageInfo(
                                                                          plural ? MessageType.added_peptide_decoys : MessageType.added_peptide_decoy,
                                                                          DocumentUI.DocumentType,
                                                                          refinementSettings.NumberOfDecoys, refinementSettings.DecoysMethod)));
                    });

                    var nodePepGroup = DocumentUI.PeptideGroups.First(nodePeptideGroup => nodePeptideGroup.IsDecoy);
                    SelectedPath = DocumentUI.GetPathTo((int)SrmDocument.Level.MoleculeGroups, DocumentUI.FindNodeIndex(nodePepGroup.Id));
                    return(true);
                }
            }
            return(false);
        }
Esempio n. 10
0
        public void TestAuditLogSerialization()
        {
            const int entryCount  = 20000;
            var       document    = new SrmDocument(SrmSettingsList.GetDefault());
            var       simpleEntry = AuditLogEntry.CreateSimpleEntry(document, MessageType.test_only, string.Empty);
            var       entries     = Enumerable.Range(0, entryCount).Select(index => simpleEntry).ToArray();

            Array.Reverse(entries);
            AuditLogEntry headEntry = null;

            foreach (var entry in entries)
            {
                if (headEntry == null)
                {
                    headEntry = entry;
                }
                else
                {
                    headEntry = entry.ChangeParent(headEntry);
                }
            }
            Assert.IsNotNull(headEntry);
            Assert.AreEqual(entryCount, headEntry.Count);
            Assert.AreEqual(headEntry.Count, headEntry.Enumerate().Count());
            var auditLogList       = new AuditLogList(headEntry);
            var serializedAuditLog = new StringWriter();
            var serializer         = new XmlSerializer(typeof(AuditLogList));

            serializer.Serialize(serializedAuditLog, auditLogList);
            var roundTrip = (AuditLogList)serializer.Deserialize(new StringReader(serializedAuditLog.ToString()));

            Assert.IsNotNull(roundTrip);
            Assert.AreEqual(auditLogList.AuditLogEntries.Count, roundTrip.AuditLogEntries.Count);
        }
Esempio n. 11
0
 public void OkDialog()
 {
     Entry = string.IsNullOrEmpty(logMessageTextBox.Text)
         ? AuditLogEntry.GetUndocumentedChangeEntry(_doc)
         : AuditLogEntry.CreateSimpleEntry(_doc, MessageType.modified_outside_of_skyline, logMessageTextBox.Text);
     DialogResult = DialogResult.OK;
 }
Esempio n. 12
0
 public void ModifyDocument(EditDescription editDescription, Func <SrmDocument, SrmDocument> action, Func <SrmDocumentPair, AuditLogEntry> logFunc = null)
 {
     if (_batchChangesOriginalDocument == null)
     {
         if (SkylineWindow != null)
         {
             SkylineWindow.ModifyDocument(editDescription.GetUndoText(DataSchemaLocalizer), action,
                                          logFunc ?? (docPair => AuditLogEntry.CreateSimpleEntry(MessageType.set_to_in_document_grid, docPair.NewDocumentType,
                                                                                                 editDescription.AuditLogParseString, editDescription.ElementRefName, CellValueToString(editDescription.Value))));
         }
         else
         {
             var doc = _documentContainer.Document;
             if (!_documentContainer.SetDocument(action(doc), doc))
             {
                 throw new InvalidOperationException(Resources
                                                     .SkylineDataSchema_VerifyDocumentCurrent_The_document_was_modified_in_the_middle_of_the_operation_);
             }
         }
         return;
     }
     VerifyDocumentCurrent(_batchChangesOriginalDocument, _documentContainer.Document);
     _batchEditDescriptions.Add(editDescription);
     _document = action(_document.BeginDeferSettingsChanges());
 }
Esempio n. 13
0
        public async Task HandleAsync(AddAuditLogEntryCommand command, CancellationToken cancellationToken = default)
        {
            var auditLog = new AuditLogEntry
            {
                UserId          = command.AuditLogEntry.UserId,
                CreatedDateTime = command.AuditLogEntry.CreatedDateTime,
                Action          = command.AuditLogEntry.Action,
                ObjectId        = command.AuditLogEntry.ObjectId,
                Log             = command.AuditLogEntry.Log,
            };

            await _auditLogRepository.AddOrUpdateAsync(auditLog);

            await _auditLogRepository.UnitOfWork.SaveChangesAsync(cancellationToken);

            await _eventLogRepository.AddOrUpdateAsync(new EventLog
            {
                EventType       = "AUDIT_LOG_ENTRY_CREATED",
                TriggeredById   = _currentUser.UserId,
                CreatedDateTime = auditLog.CreatedDateTime,
                ObjectId        = auditLog.Id.ToString(),
                Message         = auditLog.AsJsonString(),
                Published       = false,
            }, cancellationToken);

            await _eventLogRepository.UnitOfWork.SaveChangesAsync(cancellationToken);
        }
Esempio n. 14
0
        public object Read(
            object data,
            string masterPassphrase,
            params KeyValuePair <string, string>[] parameters)
        {
            FormatVersionAttribute formatVersion = FormatVersionAttribute.GetAttributeFromType(this.GetType());

            DLoggerManager.Instance.Logger.Log(DFramework.Logging.Interfaces.LoggerMessageType.VerboseHigh | DFramework.Logging.Interfaces.LoggerMessageType.Information, "Reading AuditLogEntry from JSON using serialiser '{0}'.", formatVersion);

            JObject   dataJSON  = (JObject)data;
            EntryType entryType = (EntryType)Enum.Parse(typeof(EntryType), JSONHelpers.ReadString(dataJSON, "TypeOfEntry"), true);
            DateTime  dateTime  = JSONHelpers.ReadDateTime(dataJSON, "DateTime", "HH:mm:ss dd-MM-yyyy");
            Dictionary <String, String> paramsDictionary = new Dictionary <String, String>();
            JObject entyryParams = dataJSON["Parameters"].Value <JObject>();

            foreach (JToken curToken in entyryParams.Children())
            {
                JProperty curProperty = (JProperty)curToken;
                paramsDictionary.Add(curProperty.Name,
                                     curProperty.Value.ToString());
            }
            AuditLogEntry entry = new AuditLogEntry(dateTime,
                                                    entryType,
                                                    paramsDictionary.ToArray());

            return(entry);
        }
Esempio n. 15
0
        private void InitializeTables()
        {
            List <string> tableNames = _Database.ListTables();

            tableNames = tableNames.ConvertAll(d => d.ToLower());

            if (!tableNames.Contains(USER_TABLE.ToLower()))
            {
                List <Column> userColumns = UserMaster.GetTableColumns();
                _Database.CreateTable(USER_TABLE, userColumns);
            }

            if (!tableNames.Contains(API_KEY_TABLE.ToLower()))
            {
                List <Column> apiKeyColumns = ApiKey.GetTableColumns();
                _Database.CreateTable(API_KEY_TABLE, apiKeyColumns);
            }

            if (!tableNames.Contains(PERMISSION_TABLE.ToLower()))
            {
                List <Column> permissionColumns = Permission.GetTableColumns();
                _Database.CreateTable(PERMISSION_TABLE, permissionColumns);
            }

            if (!tableNames.Contains(LOCKS_TABLE.ToLower()))
            {
                List <Column> locksColumns = UrlLock.GetTableColumns();
                _Database.CreateTable(LOCKS_TABLE, locksColumns);
            }

            if (!tableNames.Contains(CONTAINERS_TABLE.ToLower()))
            {
                List <Column> containerColumns = Container.GetTableColumns();
                _Database.CreateTable(CONTAINERS_TABLE, containerColumns);
            }

            if (!tableNames.Contains(OBJECTS_TABLE.ToLower()))
            {
                List <Column> objectColumns = ObjectMetadata.GetTableColumns();
                _Database.CreateTable(OBJECTS_TABLE, objectColumns);
            }

            if (!tableNames.Contains(CONTAINERS_KVP_TABLE.ToLower()))
            {
                List <Column> containerMetadataColumns = ContainerKeyValuePair.GetTableColumns();
                _Database.CreateTable(CONTAINERS_KVP_TABLE, containerMetadataColumns);
            }

            if (!tableNames.Contains(OBJECTS_KVP_TABLE.ToLower()))
            {
                List <Column> objectMetadataColumns = ObjectKeyValuePair.GetTableColumns();
                _Database.CreateTable(OBJECTS_KVP_TABLE, objectMetadataColumns);
            }

            if (!tableNames.Contains(AUDIT_LOG_TABLE.ToLower()))
            {
                List <Column> auditLogColumns = AuditLogEntry.GetTableColumns();
                _Database.CreateTable(AUDIT_LOG_TABLE, auditLogColumns);
            }
        }
Esempio n. 16
0
        public async Task <IActionResult> GetGuildAuditLogAsync(Snowflake guildId, [FromQuery] Dictionary <string, string> queryMap)
        {
            var args = new GetGuildAuditLogParams();

            args.LoadQueryMap(queryMap);
            args.Validate();

            var entry = new AuditLogEntry
            {
                ActionType = args.ActionType.GetValueOrDefault(AuditLogEvent.ChannelCreate)
            };

            if (args.Before.IsSpecified)
            {
                entry.Id = args.Before.Value;
            }
            if (args.UserId.IsSpecified)
            {
                entry.UserId = args.UserId.Value;
            }

            return(Ok(new AuditLog
            {
                Entries = new[] { entry }
            }));
        }
Esempio n. 17
0
 private void PerformSort(string title, Comparison <PeptideGroupDocNode> comparison, MessageType type)
 {
     ModifyDocument(title, doc =>
     {
         var listIrt      = new List <PeptideGroupDocNode>();
         var listProteins = new List <PeptideGroupDocNode>(doc.Children.Count);
         var listDecoy    = new List <PeptideGroupDocNode>();
         foreach (var nodePepGroup in doc.MoleculeGroups)
         {
             if (nodePepGroup.IsDecoy)
             {
                 listDecoy.Add(nodePepGroup);
             }
             else if (nodePepGroup.PeptideCount > 0 && nodePepGroup.Peptides.All(nodePep => nodePep.GlobalStandardType == StandardType.IRT))
             {
                 listIrt.Add(nodePepGroup);
             }
             else
             {
                 listProteins.Add(nodePepGroup);
             }
         }
         listIrt.Sort(comparison);
         listProteins.Sort(comparison);
         listDecoy.Sort(comparison);
         return((SrmDocument)doc.ChangeChildrenChecked(listIrt.Concat(listProteins).Concat(listDecoy).ToArray()));
     }, docPair => AuditLogEntry.CreateSingleMessageEntry(new MessageInfo(type, docPair.NewDocumentType)));
 }
Esempio n. 18
0
        public override Task <AddAuditLogEntryResponse> AddAuditLogEntry(AddAuditLogEntryRequest request, ServerCallContext context)
        {
            var entry = new AuditLogEntry
            {
                UserId          = Guid.Parse(request.Entry.UserId),
                ObjectId        = request.Entry.ObjectId,
                Action          = request.Entry.Action,
                Log             = request.Entry.Log,
                CreatedDateTime = request.Entry.CreatedDateTime.ToDateTimeOffset(),
            };

            _dispatcher.Dispatch(new AddOrUpdateEntityCommand <AuditLogEntry>(entry));

            var response = new AddAuditLogEntryResponse
            {
                Entry = new AuditLogEntryMessage
                {
                    Id              = entry.Id.ToString(),
                    ObjectId        = entry.ObjectId,
                    UserId          = entry.UserId.ToString(),
                    Action          = entry.Action,
                    Log             = entry.Log,
                    CreatedDateTime = Timestamp.FromDateTimeOffset(entry.CreatedDateTime),
                }
            };

            return(Task.FromResult(response));
        }
Esempio n. 19
0
 public void ClickCancel()
 {
     graphChromatograms.IsCanceled = IsUserCanceled = true;
     Program.MainWindow.ModifyDocument(Resources.AllChromatogramsGraph_btnCancel_Click_Cancel_import,
                                       doc => FilterFiles(doc, info => IsCachedFile(doc, info)),
                                       docPair => AuditLogEntry.CreateSimpleEntry(docPair.OldDoc, MessageType.canceled_import));
 }
Esempio n. 20
0
            protected override AuditLogEntry CreateEntry(SrmDocumentPair docPair)
            {
                var entry = AuditLogEntry.CreateCountChangeEntry(MessageType.imported_result,
                                                                 MessageType.imported_results, docPair.NewDocumentType, FileNames, MessageArgs.DefaultSingular, null);

                return(entry.Merge(base.CreateEntry(docPair), false));
            }
        public async Task <AuditData> BuildListOfFieldsChanged(Organisation originalOrganisation, Organisation updatedOrganisation)
        {
            CompareLogic organisationComparison = new CompareLogic(new ComparisonConfig
            {
                CompareChildren = true,
                MaxDifferences  = byte.MaxValue
            }
                                                                   );
            ComparisonResult comparisonResult = organisationComparison.Compare(originalOrganisation, updatedOrganisation);

            var updatedAt = updatedOrganisation.UpdatedAt ?? DateTime.Now;
            var updatedBy = string.IsNullOrWhiteSpace(updatedOrganisation.UpdatedBy) ? "System" : updatedOrganisation.UpdatedBy;

            var auditData = new AuditData
            {
                OrganisationId = updatedOrganisation.Id,
                UpdatedAt      = updatedAt,
                UpdatedBy      = updatedBy
            };

            List <AuditLogEntry> auditLogEntries = new List <AuditLogEntry>();

            foreach (var difference in comparisonResult.Differences)
            {
                if (_settings.IgnoredFields.Contains(difference.PropertyName))
                {
                    continue;
                }

                string propertyName = difference.PropertyName;

                AuditLogDisplayName displayNameForProperty = Enumerable.FirstOrDefault <AuditLogDisplayName>(_settings.DisplayNames, x => x.FieldName == propertyName);

                if (displayNameForProperty != null)
                {
                    propertyName = displayNameForProperty.DisplayName;
                }

                if (!updatedOrganisation.UpdatedAt.HasValue)
                {
                    updatedOrganisation.UpdatedAt = DateTime.Now;
                }

                if (String.IsNullOrWhiteSpace(updatedOrganisation.UpdatedBy))
                {
                    updatedOrganisation.UpdatedBy = "System";
                }

                AuditLogEntry entry = new AuditLogEntry
                {
                    FieldChanged  = propertyName,
                    PreviousValue = difference.Object1Value,
                    NewValue      = difference.Object2Value
                };
                auditLogEntries.Add(entry);
            }
            auditData.FieldChanges = auditLogEntries;

            return(await Task.FromResult(auditData));
        }
Esempio n. 22
0
        public Task AddLogEntry <T>(AuditLogTypes type, T logData, CancellationToken token)
        {
            var datetime = DateTime.UtcNow;
            var logEntry = new AuditLogEntry <T>(logData, type, datetime);

            return(_client.IndexAsync(new IndexRequest <AuditLogEntry <T> >(
                                          logEntry, BuildIndexName(datetime)), token));
        }
Esempio n. 23
0
            protected override AuditLogEntry CreateEntry(SrmDocumentPair docPair)
            {
                var entry = AuditLogEntry.CreateCountChangeEntry(
                    MessageType.associated_peptides_with_protein,
                    MessageType.associated_peptides_with_proteins, docPair.NewDocumentType, Proteins);

                return(entry.Merge(base.CreateEntry(docPair)));
            }
Esempio n. 24
0
        public async Task Append(int employeeId, LogActionType actionType, LogResourceType resourceType, int resourceId, string message,
                                 string oldValue = null, string newValue = null)
        {
            var logEntry = new AuditLogEntry(employeeId, actionType, resourceType, resourceId, message, oldValue, newValue);

            _dbContext.AuditLog.Add(logEntry);
            await _dbContext.SaveChangesAsync();
        }
Esempio n. 25
0
 public AuditLogRow(SkylineDataSchema dataSchema, AuditLogEntry entry, int id) : base(dataSchema)
 {
     Assume.IsNotNull(entry);
     _entry  = entry;
     Id      = new AuditLogRowId(id, 0);
     Details = ImmutableList.ValueOf(entry.AllInfo.Select((l, i) =>
                                                          new AuditLogDetailRow(this, new AuditLogRowId(id, i + 1))));
     _isMultipleUndo = GetIsMultipleUndo();
 }
Esempio n. 26
0
        public void AuditLog(string doingWhat, User user = null, AuditLogCategory category = AuditLogCategory.Unspecified, GlobalEntryId?entryId = null)
        {
            var agentLoginData = CreateAgentLoginData(Ctx, PermissionContext, user);

            SysLog(doingWhat, agentLoginData.Name);
            var entry = new AuditLogEntry(agentLoginData, doingWhat, category, entryId ?? GlobalEntryId.Empty);

            Ctx.Save(entry);
        }
        public BsonDocument BuildAuditLogEntry(AuditLogEntry logEntry)
        {
            var json = JsonConvert.SerializeObject(logEntry, Formatting.None, new JsonSerializerSettings()
            {
                ReferenceLoopHandling = ReferenceLoopHandling.Ignore
            });

            return(BsonDocument.Parse(json));
        }
Esempio n. 28
0
        public static void EnableAuditLogging(bool enable, SkylineWindow window)
        {
            Settings.Default.AuditLogging = enable;

            var entry = AuditLogEntry.CreateLogEnabledDisabledEntry(window.Document);

            window.ModifyDocumentNoUndo(doc =>
                                        doc.ChangeAuditLog(ImmutableList <AuditLogEntry> .ValueOf(doc.AuditLog.AuditLogEntries.Concat(new[] { entry }))));
        }
Esempio n. 29
0
        public void AuditLog(string doingWhat, string who, AuditLogCategory category = AuditLogCategory.Unspecified)
        {
            SysLog(doingWhat, who);

            var agentLoginData = new AgentLoginData(who);
            var entry          = new AuditLogEntry(agentLoginData, doingWhat, category, GlobalEntryId.Empty);

            Ctx.Save(entry);
        }
Esempio n. 30
0
        public void RemoveMissingResults()
        {
            var refinementSettings = new RefinementSettings {
                RemoveMissingResults = true
            };

            ModifyDocument(Resources.SkylineWindow_RemoveMissingResults_Remove_missing_results, refinementSettings.Refine,
                           docPair => AuditLogEntry.CreateSimpleEntry(MessageType.removed_missing_results, docPair.NewDocumentType));
        }
 /// <summary>
 ///     Writes the specified audit log entry.
 /// </summary>
 /// <param name="logEntry">The audit log entry.</param>
 protected override void WriteCore(AuditLogEntry logEntry)
 {
     Guard.ArgumentNotNull(logEntry, "logEntry");
     RedisDatabaseWrapper.StringSet($"{logEntry.FunctionName}:{logEntry.TransactionId}",
         JsonConvert.SerializeObject(logEntry));
 }