private void SetBackgroundColor() { Guid previousGuid = Guid.Empty; Color gray = Color.FromArgb(237, 237, 237); Color lastColor = new Color(); foreach (DataGridViewRow row in dtGrvPreview.Rows) { AuditHistory history = row.DataBoundItem as AuditHistory; if (previousGuid.Equals(Guid.Empty)) { row.DefaultCellStyle.BackColor = gray; } else if (previousGuid.Equals(history.RecordId)) { row.DefaultCellStyle.BackColor = lastColor; } else if (!history.RecordId.Equals(previousGuid) && lastColor.Equals(gray)) { row.DefaultCellStyle.BackColor = Color.White; } else { row.DefaultCellStyle.BackColor = gray; } lastColor = row.DefaultCellStyle.BackColor; previousGuid = history.RecordId; } }
//public ItemModel(ItemModel data) //{ // AuditHistoryString = data.AuditHistoryString; // AuditHistory = JsonConvert.DeserializeObject<List<History>>(AuditHistoryString); // // Update the Base // Id = data.Id; // Name = data.Name; // Description = data.Description; // // Update the extended // Value = data.Value; //} public bool Update(ItemModel data) { var latest = JsonConvert.SerializeObject(data); var previous = JsonConvert.SerializeObject(this); AuditHistory = data.AuditHistory; if (AuditHistory == null) { AuditHistory = new List <History>(); } AuditHistory.Add(new History { Note = "Upated", ChangedLatest = latest, ChangedPrevious = previous, ChangeSize = latest.Length - previous.Length }); AuditHistoryString = JsonConvert.SerializeObject(AuditHistory); // Do not update the ID, if you do, the record will be orphaned // Id = data.Id; // Update the Base Name = data.Name; Description = data.Description; // Update the extended Value = data.Value; return(true); }
public IActionResult AuditHistory(AuditHistory auditHistory) { var history = this.userService.AuditHistory(auditHistory.SearchTerm, auditHistory.SortMethod); auditHistory.LoginAudits = history; return(this.View("AuditHistory", auditHistory)); }
private DataTable LoadData() { var data = new AuditHistory(); data.FromSearchDate = DateTime.Now.AddDays(DateInterval * (-1)); data.ToSearchDate = DateTime.Now; data.PersonId = ActivityStreamAuditId; data.DataViewMode = DataViewMode; return(Framework.Components.Audit.AuditHistoryDataManager.SearchForActivityStream(data, ActivityStreamTempPageSize, CurrentIndex, SessionVariables.RequestProfile)); }
private void hlDetail_Click(object sender, RoutedEventArgs e) { dynamic d = this.CpsUserResult.SelectedItem as dynamic; AuditHistory item = new AuditHistory() { SysNo = d.SysNo }; item.Dialog = Window.ShowDialog("审核记录", item, (s, args) => { }); }
private DataTable GetData() { var dt = new DataTable(); var data = new AuditHistory(); if (!string.IsNullOrEmpty(Request.QueryString["SystemEntity"])) { data.SystemEntityId = Convert.ToInt32(Request.QueryString["SystemEntity"]); } if (!string.IsNullOrEmpty(Request.QueryString["EntityKey"])) { data.EntityKey = Convert.ToInt32(Request.QueryString["EntityKey"]); } if (!string.IsNullOrEmpty(Request.QueryString["AuditAction"])) { data.AuditActionId = Convert.ToInt32(Request.QueryString["AuditAction"]); } if (!string.IsNullOrEmpty(Request.QueryString["ActionBy"])) { data.PersonId = Convert.ToInt32(Request.QueryString["ActionBy"]); } try { if (!string.IsNullOrEmpty(Request.QueryString["Start"])) { data.FromSearchDate = DateTime.ParseExact((Request.QueryString["Start"]), "yyyy-MM-dd hh-mm-ss tt", DateTimeFormatInfo.InvariantInfo); } } catch { } try { if (!string.IsNullOrEmpty(Request.QueryString["End"])) { data.ToSearchDate = DateTime.ParseExact((Request.QueryString["End"]), "yyyy-MM-dd hh-mm-ss tt", DateTimeFormatInfo.InvariantInfo); } } catch { } dt = Framework.Components.Audit.AuditHistoryDataManager.Find(data, SessionVariables.RequestProfile); return(dt); }
public void Add(HistoryBaseModel history, int hisEntityTypeId) { var auditRepo = IoC.Container.Resolve <BaseRepositoryV2 <MedDbLogContext, AuditHistory> >(); var audit = new AuditHistory() { DrugStoreCode = history.DrugStoreCode, CreatedDatetime = DateTime.Now, HisEntityTypeID = hisEntityTypeId, HisEntityID = history.EntityID, EntityContent = JsonConvert.SerializeObject(history), ActorID = history.ActorID }; auditRepo.Add(audit); auditRepo.Commit(); }
private static void FillAuditRecordWithBaseInfo(AuditHistory auditHistory, Entity record) { auditHistory.EntityName = record.GetAttributeValue <EntityReference>("objectid").LogicalName; auditHistory.CreatedOn = record.GetAttributeValue <DateTime>("createdon"); auditHistory.ActionId = record.GetAttributeValue <OptionSetValue>("action").Value; auditHistory.OperationId = record.GetAttributeValue <OptionSetValue>("operation").Value; auditHistory.AuditId = record.GetAttributeValue <Guid>("auditid"); auditHistory.UserId = record.GetAttributeValue <EntityReference>("userid").Id; auditHistory.RecordId = record.GetAttributeValue <EntityReference>("objectid").Id; if (record.FormattedValues.Contains("action")) { auditHistory.Action = record.FormattedValues["action"]; } if (record.FormattedValues.Contains("operation")) { auditHistory.Operation = record.FormattedValues["operation"]; } if (record.GetAttributeValue <EntityReference>("userid") != null) { auditHistory.Username = record.GetAttributeValue <EntityReference>("userid").Name; } }
private DataTable GetData() { var data = new AuditHistory(); data.EntityKey = EntityKey; data.SystemEntityId = SystemEntityTypeId; DataTable dt = null; if (ViewMode == GridViewMode.Advanced) { if (AdvancedModeGrouping == GridViewAdvancedModeGrouping.TimeInterval) { data.TimeInterval = ConvertTimeIntervalInMinute(Convert.ToInt32(txtInterval.Text)); dt = Framework.Components.Audit.AuditHistoryDataManager.SearchByTimeInterval(data, SessionVariables.RequestProfile); } else if (AdvancedModeGrouping == GridViewAdvancedModeGrouping.AuditAction) { dt = Framework.Components.Audit.AuditHistoryDataManager.SearchByAuditAction(data, SessionVariables.RequestProfile); } else if (AdvancedModeGrouping == GridViewAdvancedModeGrouping.ActionByAndAuditAction) { dt = Framework.Components.Audit.AuditHistoryDataManager.SearchByActionByAndAuditAction(data, SessionVariables.RequestProfile); } } else { dt = Framework.Components.Audit.AuditHistoryDataManager.Find(data, SessionVariables.RequestProfile); } //if (dt != null && dt.Rows.Count > 0) //{ // lblHistory.Visible = true; //} return(dt); }
private List <AuditHistory> GetRecordChanges(AuditDetail detail, string recordKeyValue = "") { AuditHistory auditHistory = new AuditHistory(); Entity record = (Entity)detail.AuditRecord; List <AuditHistory> lsChanges = new List <AuditHistory>(); // Write out some of the change history information in the audit record. Console.WriteLine("\nAudit record created on: {0}", record.GetAttributeValue <DateTime>("createdon").ToLocalTime()); Console.WriteLine("Entity: {0}, Action: {1}, Operation: {2}, Transaction Id {3}", record.GetAttributeValue <EntityReference>("objectid").LogicalName, record.FormattedValues["action"], record.FormattedValues["operation"], record.GetAttributeValue <Guid>("auditid").ToString()); Console.WriteLine("USER : {0}", record.GetAttributeValue <EntityReference>("userid").Name); // Show additional details for certain AuditDetail sub-types. var detailType = detail.GetType(); if (detailType == typeof(AttributeAuditDetail) && ((AttributeAuditDetail)detail).NewValue != null) { var attributeDetail = (AttributeAuditDetail)detail; // Display the old and new attribute values. foreach (KeyValuePair <String, object> attribute in attributeDetail.NewValue.Attributes) { auditHistory = new AuditHistory(); FillAuditRecordWithBaseInfo(auditHistory, record); auditHistory.RecordKeyValue = recordKeyValue; String oldValue = "(no value)", newValue = "(no value)"; //TODO Display the lookup values of those attributes that do not contain strings. if (attributeDetail.OldValue.Contains(attribute.Key)) { oldValue = GetValue(attributeDetail.OldValue, attribute.Key); } newValue = GetValue(attributeDetail.NewValue, attribute.Key); Console.WriteLine("Attribute: {0}, old value: {1}, new value: {2}", attribute.Key, oldValue, newValue); auditHistory.OldValue = oldValue; auditHistory.NewValue = newValue; auditHistory.AttributeName = attribute.Key; lsChanges.Add(auditHistory); } foreach (KeyValuePair <String, object> attribute in attributeDetail.OldValue.Attributes) { if (!attributeDetail.NewValue.Contains(attribute.Key)) { auditHistory = new AuditHistory(); FillAuditRecordWithBaseInfo(auditHistory, record); String newValue = "(no value)"; //TODO Display the lookup values of those attributes that do not contain strings. String oldValue = GetValue(attributeDetail.OldValue, attribute.Key);// attributeDetail.OldValue[attribute.Key].ToString(); Console.WriteLine("Attribute: {0}, old value: {1}, new value: {2}", attribute.Key, oldValue, newValue); auditHistory.OldValue = oldValue; auditHistory.NewValue = newValue; auditHistory.AttributeName = attribute.Key; lsChanges.Add(auditHistory); } } } else { auditHistory = null; } return(lsChanges); }
public IEnumerable <AuditHistory> GetHistory(IQueryable <BaseAudit> list) { if (list == null || !list.Any()) { return(null); } IList <AuditHistory> hislist = new List <AuditHistory>(); BaseCaseDAL bcd = new BaseCaseDAL(); Framework.DAL.UserDAL user = new Framework.DAL.UserDAL(); var lis = list.OrderByDescending(s => s.Version).First(); foreach (var model in list) { var his = new AuditHistory(); if (model.Equals(lis)) { his.CreatUser = user.GetDisplayName(model.CreateUser); his.CreateTime = null; his.CaseStatusTest = CaseStatusHelper.GetStatsText(model.CaseStatus); his.Action = ActionTest(model, list); hislist.Add(his); } else { his.CreatUser = user.GetDisplayName(model.CreateUser); his.CreateTime = GetCommitTime(model, list); his.CaseStatusTest = CaseStatusHelper.GetStatsText(model.CaseStatus); his.Description = ""; //if (model.RejectType != null) //{ // string RejectType = ""; // string[] str = model.RejectType.Split(','); // DictionaryDAL dadal = new DictionaryDAL(); // foreach (var item in str) // { // RejectType += dadal.GetText(item) + ","; // } // RejectType = RejectType.Substring(0, RejectType.Length - 1); // if (!string.IsNullOrEmpty(model.Description)) // { // his.Description = RejectType + "<br/>" + model.Description.Replace("\n", "<br/>"); // } // else // { // his.Description = RejectType; // } //} //else //{ //if (!string.IsNullOrEmpty(model.RejectReason)) //{ // his.Description += model.RejectReason.Replace("\n", "<br/>"); //} if (!string.IsNullOrEmpty(model.Description)) { his.Description += model.Description.Replace("\n", "<br/>"); } else { his.Description += ""; } //} his.Action = ActionTest(model, list); hislist.Add(his); } } var newcasenum = list.FirstOrDefault().NewCaseNum; var basecase = bcd.GetAll(t => t.NewCaseNum == newcasenum).FirstOrDefault(); hislist.Add(new AuditHistory() { CreatUser = user.GetDisplayName(basecase.CreateUser), CreateTime = basecase.CreateTime, CaseStatusTest = "进件", Description = "", Action = "提交", }); return(hislist); }