public static List <ILoggingFilter> GetFiltersCustomView(LoggingFilterViewType viewType, int?intAppID, LoggingFilterRequestContext objAppContext = null, bool blnActiveOnly = true) { DataTable objTable = GetFilters_DataSet(intAppID, objAppContext, blnActiveOnly).Tables[0]; List <ILoggingFilter> lstModels = new List <Model.ILoggingFilter>(); foreach (DataRow objRow in objTable.Rows) { lstModels.Add(GetFilterModel(objRow, viewType: viewType)); } if (objAppContext != null) { return(QueryFiltersByAppContext(lstModels, objAppContext, viewType)); } return(lstModels); }
public static ILoggingFilter GetFilterModel(DataRow row, LoggingFilterViewType viewType = LoggingFilterViewType.Full) { ILoggingFilter objModel; if (viewType == LoggingFilterViewType.Browser) { objModel = new General.ErrorLogging.Model.LoggingFilterBrowserView(); } else if (viewType == LoggingFilterViewType.RemoteServer) { objModel = new General.ErrorLogging.Model.LoggingFilterRemoteServerView(); } else { objModel = new General.ErrorLogging.Model.LoggingFilter(); } objModel.ID = SqlConvert.ToInt32(row["FilterID"]); objModel.Name = SqlConvert.ToString(row["FilterName"]); objModel.AppID = SqlConvert.ToInt32(row["FilterAppID"]); //if (row["AppFilter"] != DBNull.Value && !StringFunctions.IsNullOrWhiteSpace(row["AppFilter"].ToString())) // objModel.AppFilter = Model.ApplicationFilterModel.FromJson<Model.ApplicationFilterModel>(row["AppFilter"].ToString()); if (row["ClientFilter"] != DBNull.Value && !StringFunctions.IsNullOrWhiteSpace(row["ClientFilter"].ToString())) { objModel.ClientFilter = Model.ClientFilterModel.FromJson <Model.ClientFilterModel>(row["ClientFilter"].ToString()); } if (row["UserFilter"] != DBNull.Value && !StringFunctions.IsNullOrWhiteSpace(row["UserFilter"].ToString())) { objModel.UserFilter = Model.UserFilterModel.FromJson <Model.UserFilterModel>(row["UserFilter"].ToString()); } if (row["EnvironmentFilter"] != DBNull.Value && !StringFunctions.IsNullOrWhiteSpace(row["EnvironmentFilter"].ToString())) { objModel.EnvironmentFilter = Model.EnvironmentFilterModel.FromJson <Model.EnvironmentFilterModel>(row["EnvironmentFilter"].ToString()); } if (row["EventFilter"] != DBNull.Value && !StringFunctions.IsNullOrWhiteSpace(row["EventFilter"].ToString())) { objModel.EventFilter = Model.EventFilterModel.FromJson <Model.EventFilterModel>(row["EventFilter"].ToString()); } objModel.Enabled = SqlConvert.ToBoolean(row["FilterEnabled"]); if (row["FilterStartDate"] != DBNull.Value) { objModel.StartDate = (DateTimeOffset)row["FilterStartDate"]; } if (row["FilterEndDate"] != DBNull.Value) { objModel.EndDate = (DateTimeOffset)row["FilterEndDate"]; } if (row["FilterPageEmail"] != DBNull.Value) { objModel.PageEmail = (EmailAddress)row["FilterPageEmail"].ToString(); } if (row["FilterPageSMS"] != DBNull.Value) { objModel.PageSMS = (PhoneNumber)row["FilterPageSMS"].ToString(); } General.FingerPrint objFingerPrint = new General.FingerPrint(); objFingerPrint.CreatedBy = SqlConvert.ToInt32(row["FilterCreatedBy"]); if (row["FilterCreateDate"] != DBNull.Value) { objFingerPrint.CreatedOn = ((DateTimeOffset)row["FilterCreateDate"]).LocalDateTime; } if (row["FilterModifyDate"] != DBNull.Value) { objFingerPrint.ModifiedOn = ((DateTimeOffset)row["FilterModifyDate"]).LocalDateTime; } objModel.FingerPrint = objFingerPrint; objModel.Custom1 = SqlConvert.ToString(row["FilterCustom1"]); objModel.Custom2 = SqlConvert.ToString(row["FilterCustom2"]); objModel.Custom3 = SqlConvert.ToString(row["FilterCustom3"]); return(objModel); }
public static List <LoggingFilterRemoteServerView> QueryFiltersByAppContext(List <LoggingFilterRemoteServerView> lstModels, LoggingFilterRequestContext objAppContext, LoggingFilterViewType viewType) { IEnumerable <LoggingFilterRemoteServerView> data = lstModels; data = data.Where(row => row.EnvironmentFilter.WildcardAll || (objAppContext.Environment.HasValue && row.EnvironmentFilter.EnvironmentList.Contains(objAppContext.Environment.Value))); return(data.ToList()); }
public static List <ILoggingFilter> QueryFiltersByAppContext(List <ILoggingFilter> lstModels, LoggingFilterRequestContext objAppContext, LoggingFilterViewType viewType) { IEnumerable <ILoggingFilter> data = lstModels; data = data.Where(row => row.EnvironmentFilter.WildcardAll || (objAppContext.Environment.HasValue && row.EnvironmentFilter.EnvironmentList.Contains(objAppContext.Environment.Value))); if (viewType != LoggingFilterViewType.RemoteServer) { data = data.Where(row => row.ClientFilter.WildcardAll || row.ClientFilter.ClientIDList.Contains <string>(objAppContext.ClientID, new CaseInsensitiveComparer())); data = data.Where(row => row.UserFilter.WildcardAll || row.UserFilter.UserIDList.Contains <string>(objAppContext.UserID, new CaseInsensitiveComparer())); } return(data.ToList()); }