示例#1
0
 public void LoadAlerts(UserActivityItem item)
 {
     if (!item.ShowImage)
     {
         imgAvatar.Visible       = false;
         recordSeperator.Visible = false;
     }
     if (item.ShowTimeGroup)
     {
         lblTimeGroup.Text       = item.TimeGrouping;
         tblTimeGroup.Visible    = true;
         recordSeperator.Visible = false;
     }
     if (!recordSeperator.Visible && !tblTimeGroup.Visible)
     {
         smallRecordSeperator.Visible = true;
     }
     lblMessage.Text = item.ActivityText;
     if (item.gropedItems != null && item.gropedItems.Count > 0)
     {
         childRecords.Visible     = true;
         repChildItems.DataSource = item.gropedItems;
         repChildItems.DataBind();
         seperateTimeStamp.Visible = true;
         lblTimeStamp.Text         = item.TimeStampText;
     }
 }
示例#2
0
        private List <UserActivityItem> CreateActivityStream(DataTable dtAuditdata)
        {
            var activitySteam = new List <UserActivityItem>();
            var dv            = dtAuditdata.DefaultView;
            var rowFilter     = String.Empty;

            rowFilter = AuditHistory.DataColumns.AuditAction + " in ('Insert', 'Update', 'Delete') ";
            //DataViewMode = "Test";
            //if (DataViewMode != "Both")
            //{
            //    if (DataViewMode == "Real Data")
            //    {
            //        rowFilter += " and " + DataModel.Framework.Audit.AuditHistory.DataColumns.EntityKey + " > 0";
            //    }
            //    else
            //    {
            //        rowFilter += " and " + DataModel.Framework.Audit.AuditHistory.DataColumns.EntityKey + " < 0";
            //    }
            //}
            var dtExcludedEntities = ActivityStreamCommon.GetExcludedSystemEntities(ActivityStreamName);

            if (dtExcludedEntities != null && dtExcludedEntities.Rows.Count > 0)
            {
                var strEntities = String.Empty;
                foreach (DataRow dr in dtExcludedEntities.Rows)
                {
                    if (!string.IsNullOrEmpty(strEntities))
                    {
                        strEntities += ", ";
                    }
                    strEntities += Convert.ToString(dr[UserPreferenceSelectedItemDataModel.DataColumns.Value]);
                }
                rowFilter += " and " + AuditHistory.DataColumns.SystemEntityId + " not in (" + strEntities + ")";
            }

            dv.RowFilter = rowFilter;
            //dv.Sort = "CreatedDate DESC";

            double appTimeZoneDifference = 0;

            try
            {
                appTimeZoneDifference = Convert.ToDouble(ConfigurationManager.AppSettings["UTCTimeZoneDifference"]);
            }
            catch { }
            var prevCreatedBy = String.Empty;
            var prevTimeGroup = String.Empty;

            if (dv.Count > 0)
            {
                RowCount = Convert.ToInt32(dtAuditdata.Rows[0]["TotalCount"]);

                dtAuditdata = dv.ToTable();
                for (var iCount = 0; iCount < dtAuditdata.Rows.Count; iCount++)
                {
                    var drv          = dtAuditdata.Rows[iCount];
                    var userActivity = new UserActivityItem();
                    var activityText = String.Empty;

                    var systemEntity   = Convert.ToString(drv[AuditHistory.DataColumns.SystemEntity]);
                    var entityRecordId = Convert.ToInt32(drv[AuditHistory.DataColumns.EntityKey]);
                    var auditAction    = Convert.ToString(drv[AuditHistory.DataColumns.AuditAction]);
                    var createdBy      = Convert.ToString(drv[AuditHistory.DataColumns.Person]);
                    var createdDate    = Convert.ToDateTime(drv[BaseDataModel.BaseDataColumns.CreatedDate]);

                    var addTimeToAlert = GetActivityTimeText(createdDate, appTimeZoneDifference);
                    userActivity.TimeGrouping = GetActivityTimeGroup(createdDate, appTimeZoneDifference);

                    //Check whether the entity record still exist in the DB,
                    //need a common search procedure in the Business Layer or change the way audit records are sent from DB

                    if (prevCreatedBy == createdBy)
                    {
                        userActivity.ShowImage = false;
                    }

                    if (userActivity.TimeGrouping != prevTimeGroup)
                    {
                        userActivity.ShowImage     = true;
                        userActivity.ShowTimeGroup = true;
                    }

                    var drs = GetGroupedRecords(systemEntity, createdDate, dtAuditdata);

                    if (drs != null && drs.Length > 1)
                    {
                        userActivity.gropedItems = new List <UserActivityChildItem>();
                        foreach (var drChild in drs)
                        {
                            var childItem        = new UserActivityChildItem();
                            var childAuditAction = Convert.ToString(drChild[AuditHistory.DataColumns.AuditAction]);
                            var childEntityKey   = Convert.ToInt32(drChild[AuditHistory.DataColumns.EntityKey]);
                            childItem.ChildText = GetChildActivityText(systemEntity, childEntityKey, childAuditAction);
                            userActivity.gropedItems.Add(childItem);
                        }
                        iCount += drs.Length - 1;
                        userActivity.TimeStampText = "\t\t\t\t\t\t<font  size ='1.5'; color='Teal'>" + " - " + addTimeToAlert + "<font/>";
                        activityText = "<font  color='Black'>" + createdBy + " changed records in  " + systemEntity + "<font/>" + "<br />";
                    }
                    else
                    {
                        addTimeToAlert = "<font  size ='1.5'; color='Teal'>" + " - " + addTimeToAlert + "<font/>";
                        activityText   = "<font  color='Black'>" + GetActivityText(createdBy, systemEntity, entityRecordId, auditAction) + "<font/>" + "<br />";
                        activityText  += "\t\t\t\t\t\t" + addTimeToAlert;
                    }

                    userActivity.ActivityText = activityText;
                    activitySteam.Add(userActivity);
                    prevCreatedBy = createdBy;
                    prevTimeGroup = userActivity.TimeGrouping;
                }
            }
            lblCount.Text = "<font color='Teal'>" + "Total Records: " + "<font/>" + "<font color='Black'>" + RowCount + "<font/>";
            return(activitySteam);
        }