Inheritance: EnumerationGraphType
Ejemplo n.º 1
0
        public void Parse(string queryString)
        {
            if (!string.IsNullOrEmpty(queryString))
            {
                var queryStrings = HttpUtility.ParseQueryString(queryString);
                if (queryStrings.HasKeys() && queryStrings.AllKeys.Contains("$filter"))
                {
                    string filter   = queryStrings["$filter"];
                    var    language = new ODataFilterLanguage();
                    Expression <Func <T, bool> > predicateExpression = language.Parse <T>(filter);
                    Filter = predicateExpression.Compile();
                }
                if (queryStrings.HasKeys() && queryStrings.AllKeys.Contains("$top"))
                {
                    string top = queryStrings["$top"];
                    ParseTop(top);
                }
                if (queryStrings.HasKeys() && queryStrings.AllKeys.Contains("$skip"))
                {
                    string skip = queryStrings["$skip"];
                    ParseSkip(skip);
                }

                if (queryStrings.HasKeys() && queryStrings.AllKeys.Contains("$orderby"))
                {
                    string            orderby       = queryStrings["$orderby"];
                    OrderByClause <T> orderbyClause = new OrderByClause <T>();
                    orderbyClause.Parse(orderby);
                    Sort          = orderbyClause.RootExpression;
                    SortDirection = orderbyClause.Direction;
                }
            }
        }
Ejemplo n.º 2
0
        public void Parse(string expression)
        {
            if (string.IsNullOrEmpty(expression))
            {
                throw new ArgumentNullException(expression);
            }

            List <string> fields = Regex.Split(expression, fieldSeparator)?.ToList();

            if (fields?.Any() == true)
            {
                int seq = 1;
                fields.ForEach(o =>
                {
                    var parts = Regex.Split(o, orderBySeparator);
                    if (parts.Length <= 2)
                    {
                        string field     = parts[0];
                        string direction = (parts.Length == 2) ? parts[1] : "asc";
                        Type t           = typeof(T);
                        var propInfo     = t.GetProperty(field, System.Reflection.BindingFlags.IgnoreCase | System.Reflection.BindingFlags.Public | System.Reflection.BindingFlags.Instance);
                        if (propInfo == null)
                        {
                            throw new ArgumentException($"Property <{field}> not found for <{t.Name}> in $orderby.");
                        }

                        var newNode = new OrderByNode <T>
                        {
                            Sequence     = seq,
                            PropertyName = propInfo.Name,
                            Direction    = (string.Compare(direction, "asc", true) == 0) ? OrderByDirectionType.Ascending : OrderByDirectionType.Descending
                        };

                        CreateExpression(newNode);
                        OrderByNodes.Add(newNode);
                        seq++;
                    }
                });
            }

            var rootNode = OrderByNodes.FirstOrDefault();

            if (rootNode != null)
            {
                RootExpression = rootNode.Expression.Compile();
                Direction      = rootNode.Direction;
            }
        }
Ejemplo n.º 3
0
 public PaginatedList <JobViewModel> GetJobAgentsandProcesses(Predicate <JobViewModel> predicate = null, string sortColumn = "", OrderByDirectionType direction = OrderByDirectionType.Ascending, int skip = 0, int take = 100)
 {
     return(repo.FindAllView(predicate, sortColumn, direction, skip, take));
 }
Ejemplo n.º 4
0
 public PaginatedList <AllQueueItemsViewModel> GetQueueItemsAndBinaryObjectIds(Predicate <AllQueueItemsViewModel> predicate = null, string sortColumn = "", OrderByDirectionType direction = OrderByDirectionType.Ascending, int skip = 0, int take = 100)
 {
     return(repo.FindAllView(predicate, sortColumn, direction, skip, take));
 }
Ejemplo n.º 5
0
 public PaginatedList <AllEmailAttachmentsViewModel> GetEmailAttachmentsAndNames(Guid emailId, Predicate <AllEmailAttachmentsViewModel> predicate = null, string sortColumn = "", OrderByDirectionType direction = OrderByDirectionType.Ascending, int skip = 0, int take = 100)
 {
     return(_emailAttachmentRepository.FindAllView(emailId, predicate, sortColumn, direction, skip, take));
 }
Ejemplo n.º 6
0
        public PaginatedList <AllQueueItemsViewModel> FindAllView(Predicate <AllQueueItemsViewModel> predicate = null, string sortColumn = "", OrderByDirectionType direction = OrderByDirectionType.Ascending, int skip = 0, int take = 100)
        {
            PaginatedList <AllQueueItemsViewModel> paginatedList = new PaginatedList <AllQueueItemsViewModel>();

            var         itemsList       = base.Find(null, j => j.IsDeleted == false);
            List <Guid> binaryObjectIds = new List <Guid>();

            if (itemsList != null && itemsList.Items != null && itemsList.Items.Count > 0)
            {
                var itemRecord = from q in itemsList.Items
                                 join a in dbContext.QueueItemAttachments on q.Id equals a.QueueItemId into table1
                                 select new AllQueueItemsViewModel
                {
                    Id                 = q?.Id,
                    Name               = q?.Name,
                    State              = q?.State,
                    StateMessage       = q?.StateMessage,
                    IsLocked           = q.IsLocked,
                    LockedBy           = q?.LockedBy,
                    LockedOnUTC        = q?.LockedOnUTC,
                    LockedUntilUTC     = q?.LockedUntilUTC,
                    LockedEndTimeUTC   = q?.LockedEndTimeUTC,
                    ExpireOnUTC        = q?.ExpireOnUTC,
                    PostponeUntilUTC   = q?.PostponeUntilUTC,
                    ErrorCode          = q?.ErrorCode,
                    ErrorMessage       = q?.ErrorMessage,
                    ErrorSerialized    = q?.ErrorSerialized,
                    Source             = q?.Source,
                    Event              = q?.Event,
                    ResultJSON         = q?.ResultJSON,
                    QueueId            = q?.QueueId,
                    CreatedOn          = q?.CreatedOn,
                    PayloadSizeInBytes = q?.PayloadSizeInBytes,
                    //list of all binary object ids that correlate to the queue item
                    BinaryObjectIds = context.QueueItemAttachments.Where(a => a.QueueItemId == q.Id)?.Select(a => a.BinaryObjectId)?.ToList()
                };

                if (!string.IsNullOrWhiteSpace(sortColumn))
                {
                    if (direction == OrderByDirectionType.Ascending)
                    {
                        itemRecord = itemRecord.OrderBy(j => j.GetType().GetProperty(sortColumn).GetValue(j)).ToList();
                    }
                    else if (direction == OrderByDirectionType.Descending)
                    {
                        itemRecord = itemRecord.OrderByDescending(j => j.GetType().GetProperty(sortColumn).GetValue(j)).ToList();
                    }
                }

                List <AllQueueItemsViewModel> filterRecord = null;
                if (predicate != null)
                {
                    filterRecord = itemRecord.ToList().FindAll(predicate);
                }
                else
                {
                    filterRecord = itemRecord.ToList();
                }

                paginatedList.Items = filterRecord.Skip(skip).Take(take).ToList();

                paginatedList.Completed   = itemsList.Completed;
                paginatedList.Impediments = itemsList.Impediments;
                paginatedList.PageNumber  = itemsList.PageNumber;
                paginatedList.PageSize    = itemsList.PageSize;
                paginatedList.ParentId    = itemsList.ParentId;
                paginatedList.Started     = itemsList.Started;
                paginatedList.TotalCount  = filterRecord?.Count;
            }

            return(paginatedList);
        }
Ejemplo n.º 7
0
        public PaginatedList <FileFolderViewModel> GetFilesFolders(bool?isFile = null, string driveName = null, Predicate <FileFolderViewModel> predicate = null, string sortColumn = "", OrderByDirectionType direction = OrderByDirectionType.Ascending, int skip = 0, int take = 100)
        {
            string adapter = GetAdapterType(driveName);

            if (adapter.Equals(AdapterType.LocalFileStorage.ToString()))
            {
                return(_localFileStorageAdapter.GetFilesFolders(isFile, driveName, predicate, sortColumn, direction, skip, take));
            }
            //else if (adapter.Equals("AzureBlobStorageAdapter") && storageProvider.Equals("FileSystem.Azure"))
            //    azureBlobStorageAdapter.SaveFile(request);
            //else if (adapter.Equals("AmazonEC2StorageAdapter") && storageProvider.Equals("FileSystem.Amazon"))
            //    amazonEC2StorageAdapter.SaveFile(request);
            //else if (adapter.Equals("GoogleBlobStorageAdapter") && storageProvider.Equals("FileSystem.Google"))
            //    googleBlobStorageAdapter.SaveFile(request);
            else
            {
                throw new EntityOperationException("Configuration is not set up for local file storage");
            }
        }
Ejemplo n.º 8
0
        public override PaginatedList <AccessRequest> Find(Guid?parentId = null, Func <AccessRequest, bool> predicate = null, Func <AccessRequest, object> sort = null, OrderByDirectionType direction = OrderByDirectionType.Ascending, int skip = 0, int take = 0)
        {
            var accessRequests = base.Find(parentId, predicate, sort, direction, skip, take);

            return(accessRequests);
        }
        public override PaginatedList <IPFencing> Find(Guid?parentId = null, Func <IPFencing, bool> predicate = null, Func <IPFencing, object> sort = null, OrderByDirectionType direction = OrderByDirectionType.Ascending, int skip = 0, int take = 0)
        {
            var iPFencingRules = base.Find(parentId, predicate, sort, direction, skip, take);

            return(iPFencingRules);
        }
Ejemplo n.º 10
0
 /// <summary>
 /// Creates new instance of OrderByClause
 /// </summary>
 public OrderByClause()
 {
     OrderByNodes = new List <OrderByNode <T> >();
     Direction    = OrderByDirectionType.Ascending;
 }
Ejemplo n.º 11
0
        public PaginatedList <AllAgentsViewModel> FindAllView(Predicate <AllAgentsViewModel> predicate = null, string sortColumn = "", OrderByDirectionType direction = OrderByDirectionType.Ascending, int skip = 0, int take = 100)
        {
            PaginatedList <AllAgentsViewModel> paginatedList = new PaginatedList <AllAgentsViewModel>();

            var itemsList = base.Find(null, a => a.IsDeleted == false);

            if (itemsList != null && itemsList.Items != null && itemsList.Items.Count > 0)
            {
                var itemRecord = from a in itemsList.Items
                                 join h in dbContext.AgentHeartbeats on a.Id equals h.AgentId into table1
                                 from h in table1.OrderByDescending(h => h.CreatedOn).Take(1).DefaultIfEmpty()
                                 select new AllAgentsViewModel
                {
                    Id                  = a?.Id,
                    Name                = a?.Name,
                    MachineName         = a?.MachineName,
                    MacAddresses        = a?.MacAddresses,
                    IsEnabled           = a.IsEnabled,
                    LastReportedOn      = h?.LastReportedOn,
                    LastReportedStatus  = h?.LastReportedStatus,
                    LastReportedWork    = h?.LastReportedWork,
                    LastReportedMessage = h?.LastReportedMessage,
                    IsHealthy           = h?.IsHealthy,
                    Status              = a.IsConnected == false ? "Not Connected": h?.LastReportedOn == null ? "Disconnected" : ((DateTime)h?.LastReportedOn).AddMinutes(5) > DateTime.UtcNow ? "Connected" : "Disconnected",
                    CredentialId        = a?.CredentialId,
                    CreatedOn           = a?.CreatedOn
                };

                if (!string.IsNullOrWhiteSpace(sortColumn))
                {
                    if (direction == OrderByDirectionType.Ascending)
                    {
                        itemRecord = itemRecord.OrderBy(j => j.GetType().GetProperty(sortColumn).GetValue(j)).ToList();
                    }
                    else if (direction == OrderByDirectionType.Descending)
                    {
                        itemRecord = itemRecord.OrderByDescending(j => j.GetType().GetProperty(sortColumn).GetValue(j)).ToList();
                    }
                }

                List <AllAgentsViewModel> filterRecord = null;
                if (predicate != null)
                {
                    filterRecord = itemRecord.ToList().FindAll(predicate);
                }
                else
                {
                    filterRecord = itemRecord.ToList();
                }

                paginatedList.Items = filterRecord.Skip(skip).Take(take).ToList();

                paginatedList.Completed   = itemsList.Completed;
                paginatedList.Impediments = itemsList.Impediments;
                paginatedList.PageNumber  = itemsList.PageNumber;
                paginatedList.PageSize    = itemsList.PageSize;
                paginatedList.ParentId    = itemsList.ParentId;
                paginatedList.Started     = itemsList.Started;
                paginatedList.TotalCount  = filterRecord?.Count;
            }

            return(paginatedList);
        }
Ejemplo n.º 12
0
        public PaginatedList <AuditLogViewModel> FindAllView(Predicate <AuditLogViewModel> predicate = null, string sortColumn = "", OrderByDirectionType direction = OrderByDirectionType.Ascending, int skip = 0, int take = 100)
        {
            PaginatedList <AuditLogViewModel> paginatedList = new PaginatedList <AuditLogViewModel>();

            var auditLogsList = base.Find(null, j => j.IsDeleted == false);

            if (auditLogsList != null && auditLogsList.Items != null && auditLogsList.Items.Count > 0)
            {
                var auditLogRecord = from a in auditLogsList.Items
                                     select new AuditLogViewModel
                {
                    Id          = a?.Id,
                    CreatedOn   = a?.CreatedOn,
                    CreatedBy   = a?.CreatedBy,
                    MethodName  = a?.MethodName,
                    ObjectId    = a?.ObjectId,
                    ServiceName = ((bool)(a?.MethodName.Contains("Login")) ? "Identity.Auth" : ((bool)(a?.ServiceName.Contains("BinaryObject")) ? "Files" : GetServiceName(a)))
                };

                if (!string.IsNullOrWhiteSpace(sortColumn))
                {
                    if (direction == OrderByDirectionType.Ascending)
                    {
                        auditLogRecord = auditLogRecord.OrderBy(s => s.GetType().GetProperty(sortColumn).GetValue(s)).ToList();
                    }
                    else if (direction == OrderByDirectionType.Descending)
                    {
                        auditLogRecord = auditLogRecord.OrderByDescending(s => s.GetType().GetProperty(sortColumn).GetValue(s)).ToList();
                    }
                }

                List <AuditLogViewModel> filterRecord = null;
                if (predicate != null)
                {
                    filterRecord = auditLogRecord.ToList().FindAll(predicate);
                }
                else
                {
                    filterRecord = auditLogRecord.ToList();
                }

                paginatedList.Items = filterRecord.Skip(skip).Take(take).ToList();

                paginatedList.Completed   = auditLogsList.Completed;
                paginatedList.Impediments = auditLogsList.Impediments;
                paginatedList.PageNumber  = auditLogsList.PageNumber;
                paginatedList.PageSize    = auditLogsList.PageSize;
                paginatedList.ParentId    = auditLogsList.ParentId;
                paginatedList.Started     = auditLogsList.Started;
                paginatedList.TotalCount  = filterRecord?.Count;
            }

            return(paginatedList);
        }
Ejemplo n.º 13
0
 public PaginatedList <AllSchedulesViewModel> GetScheduleAgentsandAutomations(Predicate <AllSchedulesViewModel> predicate = null, string sortColumn = "", OrderByDirectionType direction = OrderByDirectionType.Ascending, int skip = 0, int take = 100)
 {
     return(_repo.FindAllView(predicate, sortColumn, direction, skip, take));
 }
        public PaginatedList <ProcessExecutionViewModel> FindAllView(Predicate <ProcessExecutionViewModel> predicate = null, string sortColumn = "", OrderByDirectionType direction = OrderByDirectionType.Ascending, int skip = 0, int take = 100)
        {
            PaginatedList <ProcessExecutionViewModel> paginatedList = new PaginatedList <ProcessExecutionViewModel>();

            var processExecutionsList = base.Find(null, e => e.IsDeleted == false);

            if (processExecutionsList != null && processExecutionsList.Items != null && processExecutionsList.Items.Count > 0)
            {
                var processExecutionRecord = from e in processExecutionsList.Items
                                             join a in dbContext.Agents on e.AgentID equals a.Id into table1
                                             from a in table1.DefaultIfEmpty()
                                             join p in dbContext.Processes on e.ProcessID equals p.Id into table2
                                             from p in table2.DefaultIfEmpty()
                                             select new ProcessExecutionViewModel
                {
                    Id             = e?.Id,
                    AgentName      = a?.Name,
                    ProcessName    = p?.Name,
                    JobID          = e?.JobID,
                    ProcessID      = (p == null || p.Id == null) ? Guid.Empty : p.Id.Value,
                    AgentID        = (a == null || a.Id == null) ? Guid.Empty : a.Id.Value,
                    StartedOn      = e?.StartedOn,
                    CompletedOn    = e?.CompletedOn,
                    Trigger        = e?.Trigger,
                    TriggerDetails = e?.TriggerDetails,
                    Status         = e?.Status,
                    HasErrors      = e?.HasErrors,
                    ErrorMessage   = e?.ErrorMessage,
                    ErrorDetails   = e?.ErrorDetails
                };

                if (!string.IsNullOrWhiteSpace(sortColumn))
                {
                    if (direction == OrderByDirectionType.Ascending)
                    {
                        processExecutionRecord = processExecutionRecord.OrderBy(e => e.GetType().GetProperty(sortColumn).GetValue(e)).ToList();
                    }
                    else if (direction == OrderByDirectionType.Descending)
                    {
                        processExecutionRecord = processExecutionRecord.OrderByDescending(e => e.GetType().GetProperty(sortColumn).GetValue(e)).ToList();
                    }
                }

                List <ProcessExecutionViewModel> filterRecord = null;
                if (predicate != null)
                {
                    filterRecord = processExecutionRecord.ToList().FindAll(predicate);
                }
                else
                {
                    filterRecord = processExecutionRecord.ToList();
                }

                paginatedList.Items = filterRecord.Skip(skip).Take(take).ToList();

                paginatedList.Completed   = processExecutionsList.Completed;
                paginatedList.Impediments = processExecutionsList.Impediments;
                paginatedList.PageNumber  = processExecutionsList.PageNumber;
                paginatedList.PageSize    = processExecutionsList.PageSize;
                paginatedList.ParentId    = processExecutionsList.ParentId;
                paginatedList.Started     = processExecutionsList.Started;
                paginatedList.TotalCount  = filterRecord?.Count;//processExecutionsList.TotalCount;
            }

            return(paginatedList);
        }
Ejemplo n.º 15
0
        public PaginatedList <AgentHeartbeat> FindAllHeartbeats(Guid agentId, Predicate <AgentHeartbeat> predicate = null, string sortColumn = "", OrderByDirectionType direction = OrderByDirectionType.Ascending, int skip = 0, int take = 100)
        {
            PaginatedList <AgentHeartbeat> paginatedList = new PaginatedList <AgentHeartbeat>();

            var itemsList = base.Find(null, h => h.IsDeleted == false && h.AgentId == agentId);

            if (itemsList != null && itemsList.Items != null && itemsList.Items.Count > 0)
            {
                var itemRecord = from h in itemsList.Items
                                 join a in dbContext.BinaryObjects on h.AgentId equals a.Id into table1
                                 from a in table1.DefaultIfEmpty()
                                 select new AgentHeartbeat
                {
                    AgentId             = h.AgentId,
                    LastReportedOn      = h?.LastReportedOn,
                    LastReportedStatus  = h?.LastReportedStatus,
                    LastReportedWork    = h?.LastReportedWork,
                    LastReportedMessage = h?.LastReportedMessage,
                    IsHealthy           = h?.IsHealthy,
                    Id        = h?.Id,
                    IsDeleted = h?.IsDeleted,
                    CreatedBy = h?.CreatedBy,
                    CreatedOn = h?.CreatedOn,
                    DeletedBy = h?.DeletedBy,
                    DeleteOn  = h?.DeleteOn,
                    Timestamp = h?.Timestamp,
                    UpdatedOn = h?.UpdatedOn,
                    UpdatedBy = h?.UpdatedBy
                };

                if (!string.IsNullOrWhiteSpace(sortColumn))
                {
                    if (direction == OrderByDirectionType.Ascending)
                    {
                        itemRecord = itemRecord.OrderBy(j => j.GetType().GetProperty(sortColumn).GetValue(j)).ToList();
                    }
                    else if (direction == OrderByDirectionType.Descending)
                    {
                        itemRecord = itemRecord.OrderByDescending(j => j.GetType().GetProperty(sortColumn).GetValue(j)).ToList();
                    }
                }

                List <AgentHeartbeat> filterRecord = null;
                if (predicate != null)
                {
                    filterRecord = itemRecord.ToList().FindAll(predicate);
                }
                else
                {
                    filterRecord = itemRecord.ToList();
                }

                paginatedList.Items = filterRecord.Skip(skip).Take(take).ToList();


                if (skip == 0 || take == 0)
                {
                    paginatedList.PageNumber = 0;
                    paginatedList.PageSize   = 0;
                }
                else
                {
                    int pageNumber = skip;
                    if (skip != 0 && take != 0)
                    {
                        pageNumber = skip / take;
                    }

                    paginatedList.PageNumber = pageNumber;
                    paginatedList.PageSize   = take;
                }
                paginatedList.Completed   = itemsList.Completed;
                paginatedList.Impediments = itemsList.Impediments;
                paginatedList.ParentId    = itemsList.ParentId;
                paginatedList.Started     = itemsList.Started;
                paginatedList.TotalCount  = filterRecord?.Count;
            }

            return(paginatedList);
        }
Ejemplo n.º 16
0
        public PaginatedList <AssetViewModel> FindAllView(Predicate <AssetViewModel> predicate = null, string sortColumn = "", OrderByDirectionType direction = OrderByDirectionType.Ascending, int skip = 0, int take = 100)
        {
            PaginatedList <AssetViewModel> paginatedList = new PaginatedList <AssetViewModel>();

            var itemsList = base.Find(null, j => j.IsDeleted == false);

            if (itemsList != null && itemsList.Items != null && itemsList.Items.Count > 0)
            {
                var itemRecord = from p in itemsList.Items
                                 join a in dbContext.Agents on p.AgentId equals a.Id into table1
                                 from a in table1.DefaultIfEmpty()
                                 join f in dbContext.StorageFiles on p.FileId equals f.Id into table2
                                 from f in table2.DefaultIfEmpty()
                                 select new AssetViewModel
                {
                    Id          = p?.Id,
                    Name        = p?.Name,
                    Type        = p?.Type,
                    TextValue   = p.TextValue,
                    NumberValue = p.NumberValue,
                    JsonValue   = p.JsonValue,
                    FileId      = p?.FileId,
                    SizeInBytes = p.SizeInBytes,
                    AgentId     = p.AgentId,
                    CreatedOn   = p.CreatedOn,
                    CreatedBy   = p.CreatedBy,
                    AgentName   = a?.Name,
                    FileName    = f?.Name
                };

                if (!string.IsNullOrWhiteSpace(sortColumn))
                {
                    if (direction == OrderByDirectionType.Ascending)
                    {
                        itemRecord = itemRecord.OrderBy(j => j.GetType().GetProperty(sortColumn).GetValue(j)).ToList();
                    }
                    else if (direction == OrderByDirectionType.Descending)
                    {
                        itemRecord = itemRecord.OrderByDescending(j => j.GetType().GetProperty(sortColumn).GetValue(j)).ToList();
                    }
                }

                List <AssetViewModel> filterRecord = null;
                if (predicate != null)
                {
                    filterRecord = itemRecord.ToList().FindAll(predicate);
                }
                else
                {
                    filterRecord = itemRecord.ToList();
                }

                paginatedList.Items = filterRecord.Skip(skip).Take(take).ToList();

                paginatedList.Completed   = itemsList.Completed;
                paginatedList.Impediments = itemsList.Impediments;
                paginatedList.PageNumber  = itemsList.PageNumber;
                paginatedList.PageSize    = itemsList.PageSize;
                paginatedList.ParentId    = itemsList.ParentId;
                paginatedList.Started     = itemsList.Started;
                paginatedList.TotalCount  = filterRecord?.Count;
            }

            return(paginatedList);
        }
        public PaginatedList <FileFolderViewModel> FindAllFilesFoldersView(Guid?driveId, Predicate <FileFolderViewModel> predicate = null, string sortColumn = "", OrderByDirectionType direction = OrderByDirectionType.Ascending, int skip = 0, int take = 100, string path = null)
        {
            PaginatedList <FileFolderViewModel> paginatedList = new PaginatedList <FileFolderViewModel>();
            var folderItemsList = new PaginatedList <StorageFolder>();

            if (string.IsNullOrEmpty(path))
            {
                folderItemsList = base.Find(null, j => j.IsDeleted == false && j.StorageDriveId == driveId);
            }
            else
            {
                path            = path + Path.DirectorySeparatorChar;
                folderItemsList = base.Find(null, j => j.IsDeleted == false && j.StorageDriveId == driveId && j.StoragePath.Contains(path));
            }

            if (folderItemsList != null && folderItemsList.Items != null && folderItemsList.Items.Count > 0)
            {
                var folderItemRecord = from a in folderItemsList.Items
                                       join b in dbContext.StorageFolders on a.ParentFolderId equals b.Id into table1
                                       from b in table1.DefaultIfEmpty()
                                       join c in dbContext.StorageFolders on a.Id equals c.ParentFolderId into table2
                                       from c in table1.DefaultIfEmpty()
                                       join d in dbContext.StorageDrives on a.StorageDriveId equals d.Id into table3
                                       from d in table3.DefaultIfEmpty()
                                       select new FileFolderViewModel
                {
                    Name            = a?.Name,
                    Id              = a?.Id,
                    ContentType     = "Folder",
                    CreatedBy       = a?.CreatedBy,
                    CreatedOn       = a?.CreatedOn,
                    FullStoragePath = a?.StoragePath,
                    HasChild        = c?.ParentFolderId != null ? true : false,
                    IsFile          = false,
                    ParentId        = a?.ParentFolderId,
                    StoragePath     = b?.StoragePath != null ? b?.StoragePath : d?.Name,
                    Size            = a?.SizeInBytes,
                    StorageDriveId  = a?.StorageDriveId
                };

                if (!string.IsNullOrWhiteSpace(sortColumn))
                {
                    if (direction == OrderByDirectionType.Ascending)
                    {
                        folderItemRecord = folderItemRecord.OrderBy(j => j.GetType().GetProperty(sortColumn).GetValue(j)).ToList();
                    }
                    else if (direction == OrderByDirectionType.Descending)
                    {
                        folderItemRecord = folderItemRecord.OrderByDescending(j => j.GetType().GetProperty(sortColumn).GetValue(j)).ToList();
                    }
                }

                var fileItemsList = new PaginatedList <StorageFile>();
                if (string.IsNullOrEmpty(path))
                {
                    fileItemsList = _storageFileRepository.Find(null, j => j.IsDeleted == false && j.StorageDriveId == driveId);
                }
                else
                {
                    path          = path + Path.DirectorySeparatorChar;
                    fileItemsList = _storageFileRepository.Find(null, j => j.IsDeleted == false && j.StorageDriveId == driveId && j.StoragePath.Contains(path));
                }

                if (fileItemsList != null && fileItemsList.Items != null && fileItemsList.Items.Count > 0)
                {
                    var fileItemRecord = from a in fileItemsList.Items
                                         join b in dbContext.StorageFolders on a.StorageFolderId equals b.Id into table1
                                         from b in table1.DefaultIfEmpty()
                                         join c in dbContext.StorageDrives on a.StorageDriveId equals c.Id into table2
                                         from c in table2.DefaultIfEmpty()
                                         select new FileFolderViewModel
                    {
                        Name            = a?.Name,
                        Id              = a?.Id,
                        ContentType     = a?.ContentType,
                        CreatedBy       = a?.CreatedBy,
                        CreatedOn       = a?.CreatedOn,
                        FullStoragePath = a?.StoragePath,
                        HasChild        = false,
                        IsFile          = true,
                        ParentId        = a?.StorageFolderId,
                        StoragePath     = b?.StoragePath != null ? b?.StoragePath : c?.Name,
                        Size            = a?.SizeInBytes,
                        StorageDriveId  = a?.StorageDriveId
                    };

                    if (!string.IsNullOrWhiteSpace(sortColumn))
                    {
                        if (direction == OrderByDirectionType.Ascending)
                        {
                            fileItemRecord = fileItemRecord.OrderBy(j => j.GetType().GetProperty(sortColumn).GetValue(j)).ToList();
                        }
                        else if (direction == OrderByDirectionType.Descending)
                        {
                            fileItemRecord = fileItemRecord.OrderByDescending(j => j.GetType().GetProperty(sortColumn).GetValue(j)).ToList();
                        }
                    }

                    List <FileFolderViewModel> filterRecord = null;
                    List <FileFolderViewModel> itemRecord   = null;
                    if (folderItemRecord != null || folderItemRecord.Any())
                    {
                        itemRecord = folderItemRecord.ToList();
                        itemRecord.AddRange(fileItemRecord);
                    }
                    else
                    {
                        itemRecord = fileItemRecord.ToList();
                    }

                    if (predicate != null)
                    {
                        filterRecord = itemRecord.ToList().FindAll(predicate);
                    }
                    else
                    {
                        filterRecord = itemRecord.ToList();
                    }

                    paginatedList.Items = filterRecord.Skip(skip).Take(take).ToList();

                    paginatedList.Completed   = fileItemsList.Completed;
                    paginatedList.Impediments = fileItemsList.Impediments;
                    paginatedList.PageNumber  = fileItemsList.PageNumber;
                    paginatedList.PageSize    = fileItemsList.PageSize;
                    paginatedList.ParentId    = fileItemsList.ParentId;
                    paginatedList.Started     = fileItemsList.Started;
                    paginatedList.TotalCount  = filterRecord?.Count;
                }
                else
                {
                    List <FileFolderViewModel> filterRecord = null;
                    if (predicate != null)
                    {
                        filterRecord = folderItemRecord.ToList().FindAll(predicate);
                    }
                    else
                    {
                        filterRecord = folderItemRecord.ToList();
                    }

                    paginatedList.Items = filterRecord.Skip(skip).Take(take).ToList();

                    paginatedList.Completed   = folderItemsList.Completed;
                    paginatedList.Impediments = folderItemsList.Impediments;
                    paginatedList.PageNumber  = folderItemsList.PageNumber;
                    paginatedList.PageSize    = folderItemsList.PageSize;
                    paginatedList.ParentId    = folderItemsList.ParentId;
                    paginatedList.Started     = folderItemsList.Started;
                    paginatedList.TotalCount  = filterRecord?.Count;
                }
            }

            return(paginatedList);
        }
        public PaginatedList <TeamMemberViewModel> GetPeopleInOrganization(Guid organizationId, string sortColumn, OrderByDirectionType direction = OrderByDirectionType.Ascending, int skip = 0, int take = 100)
        {
            PaginatedList <TeamMemberViewModel> team = new PaginatedList <TeamMemberViewModel>
            {
                ParentId = organizationId
            };

            var org = _organizationRepo.GetOne(organizationId);

            if (org == null)
            {
                throw new KeyNotFoundException();
            }

            bool   orgHasEmailDomain = false;
            string emailDomainWithAt = string.Empty;

            var members = _organzationMemberRepo.Find(organizationId);

            team.TotalCount = members.Items.Count;

            var personIds = members.Items.Select(om => om.PersonId).Distinct().ToArray();

            var people = _personRepo.Find(null, p => personIds.Contains(p.Id));
            var emails = _emailVerificationRepository.Find(null, e => personIds.Contains(e.PersonId));

            foreach (OrganizationMember member in members.Items.Skip(skip).Take(take))
            {
                TeamMemberViewModel teamMember = new TeamMemberViewModel
                {
                    OrganizationMemberId = member.Id.Value,
                    PersonId             = member.PersonId.Value,
                    JoinedOn             = member.CreatedOn.Value,
                    InvitedBy            = member.InvitedBy,
                    IsAdmin = member.IsAdministrator.GetValueOrDefault(false)
                };

                var person = people.Items.Where(p => p.Id.Equals(member.PersonId)).FirstOrDefault();
                if (person != null)
                {
                    teamMember.UserName = person.Name;
                    teamMember.Name     = person.Name;
                    teamMember.Status   = "InActive";
                    if (orgHasEmailDomain)
                    {
                        var matchingEmailList     = emails.Items.Where(e => e.PersonId.Equals(member.PersonId) && e.Address.EndsWith(emailDomainWithAt)).ToList();
                        var orderedList           = matchingEmailList.OrderBy(x => x.CreatedOn);
                        var correctEmailForMember = orderedList.FirstOrDefault();

                        if (correctEmailForMember != null)
                        {
                            teamMember.EmailAddress = correctEmailForMember.Address;
                            teamMember.Status       = correctEmailForMember.IsVerified.GetValueOrDefault(false) ? "Active" : "InActive";
                        }
                    }
                    if (string.IsNullOrEmpty(teamMember.EmailAddress))
                    {
                        var matchingEmailList     = emails.Items.Where(e => e.PersonId.Equals(member.PersonId)).ToList();
                        var orderedList           = matchingEmailList.OrderBy(x => x.CreatedOn);
                        var correctEmailForMember = orderedList.FirstOrDefault();

                        if (correctEmailForMember != null)
                        {
                            teamMember.EmailAddress = correctEmailForMember.Address;
                            teamMember.Status       = correctEmailForMember.IsVerified.GetValueOrDefault(false) ? "Active" : "InActive";
                        }
                    }
                }

                team.Add(teamMember);
            }

            if (!string.IsNullOrWhiteSpace(sortColumn))
            {
                if (direction == OrderByDirectionType.Ascending)
                {
                    team.Items = team.Items.OrderBy(t => t.GetType().GetProperty(sortColumn).GetValue(t)).ToList();
                }
                else if (direction == OrderByDirectionType.Descending)
                {
                    team.Items = team.Items.OrderByDescending(t => t.GetType().GetProperty(sortColumn).GetValue(t)).ToList();
                }
            }

            return(team);
        }
        public PaginatedList <FileFolderViewModel> FindAllView(Guid?driveId, Predicate <FileFolderViewModel> predicate = null, string sortColumn = "", OrderByDirectionType direction = OrderByDirectionType.Ascending, int skip = 0, int take = 100)
        {
            PaginatedList <FileFolderViewModel> paginatedList = new PaginatedList <FileFolderViewModel>();
            var itemsList = base.Find(null, j => j.IsDeleted == false && j.ServerDriveId == driveId);

            if (itemsList != null && itemsList.Items != null && itemsList.Items.Count > 0)
            {
                var itemRecord = from a in itemsList.Items
                                 join b in dbContext.ServerFolders on a.StorageFolderId equals b.Id into table1
                                 from b in table1.DefaultIfEmpty()
                                 join c in dbContext.ServerDrives on a.ServerDriveId equals c.Id into table2
                                 from c in table2.DefaultIfEmpty()
                                 select new FileFolderViewModel
                {
                    Name            = a?.Name,
                    Id              = a?.Id,
                    ContentType     = a?.ContentType,
                    CreatedBy       = a?.CreatedBy,
                    CreatedOn       = a?.CreatedOn,
                    FullStoragePath = a?.StoragePath,
                    HasChild        = false,
                    IsFile          = true,
                    ParentId        = a?.StorageFolderId,
                    StoragePath     = b?.StoragePath != null ? b?.StoragePath : c?.Name,
                    Size            = a?.SizeInBytes,
                    StorageDriveId  = a?.ServerDriveId
                };

                if (!string.IsNullOrWhiteSpace(sortColumn))
                {
                    if (direction == OrderByDirectionType.Ascending)
                    {
                        itemRecord = itemRecord.OrderBy(j => j.GetType().GetProperty(sortColumn).GetValue(j)).ToList();
                    }
                    else if (direction == OrderByDirectionType.Descending)
                    {
                        itemRecord = itemRecord.OrderByDescending(j => j.GetType().GetProperty(sortColumn).GetValue(j)).ToList();
                    }
                }

                List <FileFolderViewModel> filterRecord = null;
                if (predicate != null)
                {
                    filterRecord = itemRecord.ToList().FindAll(predicate);
                }
                else
                {
                    filterRecord = itemRecord.ToList();
                }

                paginatedList.Items = filterRecord.Skip(skip).Take(take).ToList();

                paginatedList.Completed   = itemsList.Completed;
                paginatedList.Impediments = itemsList.Impediments;
                paginatedList.PageNumber  = itemsList.PageNumber;
                paginatedList.PageSize    = itemsList.PageSize;
                paginatedList.ParentId    = itemsList.ParentId;
                paginatedList.Started     = itemsList.Started;
                paginatedList.TotalCount  = filterRecord?.Count;
            }

            return(paginatedList);
        }
Ejemplo n.º 20
0
        public PaginatedList <SubscriptionAttemptViewModel> FindAllView(Predicate <SubscriptionAttemptViewModel> predicate = null, string sortColumn = "", OrderByDirectionType direction = OrderByDirectionType.Ascending, int skip = 0, int take = 100)
        {
            PaginatedList <SubscriptionAttemptViewModel> paginatedList = new PaginatedList <SubscriptionAttemptViewModel>();

            var attemptList = base.Find(null, a => a.IsDeleted == false);

            if (attemptList != null && attemptList.Items != null && attemptList.Items.Count > 0)
            {
                var attemptRecord = from a in attemptList.Items
                                    join s in dbContext.IntegrationEventSubscriptions on a.IntegrationEventSubscriptionID equals s.Id into table1
                                    from s in table1.DefaultIfEmpty()
                                    select new SubscriptionAttemptViewModel
                {
                    Id            = a?.Id,
                    CreatedOn     = a?.CreatedOn,
                    CreatedBy     = a?.CreatedBy,
                    TransportType = (s == null || s.Id == null) ? null : s.TransportType.ToString(),
                    EventLogID    = a?.EventLogID,
                    IntegrationEventSubscriptionID = a?.IntegrationEventSubscriptionID,
                    IntegrationEventName           = a.IntegrationEventName,
                    Status         = a?.Status,
                    AttemptCounter = a.AttemptCounter
                };

                if (!string.IsNullOrWhiteSpace(sortColumn))
                {
                    if (direction == OrderByDirectionType.Ascending)
                    {
                        attemptRecord = attemptRecord.OrderBy(j => j.GetType().GetProperty(sortColumn).GetValue(j)).ToList();
                    }
                    else if (direction == OrderByDirectionType.Descending)
                    {
                        attemptRecord = attemptRecord.OrderByDescending(j => j.GetType().GetProperty(sortColumn).GetValue(j)).ToList();
                    }
                }

                List <SubscriptionAttemptViewModel> filterRecord = null;
                if (predicate != null)
                {
                    filterRecord = attemptRecord.ToList().FindAll(predicate);
                }
                else
                {
                    filterRecord = attemptRecord.ToList();
                }

                paginatedList.Items = filterRecord.Skip(skip).Take(take).ToList();

                paginatedList.Completed   = attemptList.Completed;
                paginatedList.Impediments = attemptList.Impediments;
                paginatedList.PageNumber  = attemptList.PageNumber;
                paginatedList.PageSize    = attemptList.PageSize;
                paginatedList.ParentId    = attemptList.ParentId;
                paginatedList.Started     = attemptList.Started;
                paginatedList.TotalCount  = filterRecord?.Count;
            }

            return(paginatedList);
        }
Ejemplo n.º 21
0
 public PaginatedList <AutomationExecutionViewModel> GetAutomationAndAgentNames(Predicate <AutomationExecutionViewModel> predicate = null, string sortColumn = "", OrderByDirectionType direction = OrderByDirectionType.Ascending, int skip = 0, int take = 100)
 {
     return(repo.FindAllView(predicate, sortColumn, direction, skip, take));
 }
        public PaginatedList <AllEmailAttachmentsViewModel> FindAllView(Guid emailId, Predicate <AllEmailAttachmentsViewModel> predicate = null, string sortColumn = "", OrderByDirectionType direction = OrderByDirectionType.Ascending, int skip = 0, int take = 100)
        {
            PaginatedList <AllEmailAttachmentsViewModel> paginatedList = new PaginatedList <AllEmailAttachmentsViewModel>();

            var         itemsList       = base.Find(null, j => j.IsDeleted == false && j.EmailId == emailId);
            List <Guid> binaryObjectIds = new List <Guid>();

            if (itemsList != null && itemsList.Items != null && itemsList.Items.Count > 0)
            {
                var itemRecord = from a in itemsList.Items
                                 join b in dbContext.BinaryObjects on a.BinaryObjectId equals b.Id into table1
                                 from b in table1.DefaultIfEmpty()
                                 select new AllEmailAttachmentsViewModel
                {
                    BinaryObjectId = (Guid)(a?.BinaryObjectId),
                    SizeInBytes    = (long)(a?.SizeInBytes),
                    EmailId        = (Guid)(a?.EmailId),
                    Name           = b?.Name
                };

                if (!string.IsNullOrWhiteSpace(sortColumn))
                {
                    if (direction == OrderByDirectionType.Ascending)
                    {
                        itemRecord = itemRecord.OrderBy(j => j.GetType().GetProperty(sortColumn).GetValue(j)).ToList();
                    }
                    else if (direction == OrderByDirectionType.Descending)
                    {
                        itemRecord = itemRecord.OrderByDescending(j => j.GetType().GetProperty(sortColumn).GetValue(j)).ToList();
                    }
                }

                List <AllEmailAttachmentsViewModel> filterRecord = null;
                if (predicate != null)
                {
                    filterRecord = itemRecord.ToList().FindAll(predicate);
                }
                else
                {
                    filterRecord = itemRecord.ToList();
                }

                paginatedList.Items = filterRecord.Skip(skip).Take(take).ToList();

                paginatedList.Completed   = itemsList.Completed;
                paginatedList.Impediments = itemsList.Impediments;
                paginatedList.PageNumber  = itemsList.PageNumber;
                paginatedList.PageSize    = itemsList.PageSize;
                paginatedList.ParentId    = itemsList.ParentId;
                paginatedList.Started     = itemsList.Started;
                paginatedList.TotalCount  = filterRecord?.Count;
            }

            return(paginatedList);
        }
Ejemplo n.º 23
0
        public PaginatedList <CredentialViewModel> FindAllView(Predicate <CredentialViewModel> predicate = null, string sortColumn = "", OrderByDirectionType direction = OrderByDirectionType.Ascending, int skip = 0, int take = 100)
        {
            PaginatedList <CredentialViewModel> paginatedList = new PaginatedList <CredentialViewModel>();

            paginatedList.TotalCount = 0;

            var itemsList = base.Find(null, j => j.IsDeleted == false);

            if (itemsList != null && itemsList.Items != null && itemsList.Items.Count > 0)
            {
                var itemRecord = from c in itemsList.Items
                                 join a in dbContext.Agents on c.AgentId equals a.Id into table1
                                 from a in table1.DefaultIfEmpty()
                                 select new CredentialViewModel
                {
                    Id           = c.Id,
                    Name         = c.Name,
                    Provider     = c.Provider,
                    StartDate    = c.StartDate,
                    EndDate      = c.EndDate,
                    Domain       = c.Domain,
                    UserName     = c.UserName,
                    PasswordHash = c.PasswordHash,
                    Certificate  = c.Certificate,
                    AgentId      = c.AgentId,
                    AgentName    = a?.Name
                };

                if (!string.IsNullOrWhiteSpace(sortColumn))
                {
                    if (direction == OrderByDirectionType.Ascending)
                    {
                        itemRecord = itemRecord.OrderBy(j => j.GetType().GetProperty(sortColumn).GetValue(j)).ToList();
                    }
                    else if (direction == OrderByDirectionType.Descending)
                    {
                        itemRecord = itemRecord.OrderByDescending(j => j.GetType().GetProperty(sortColumn).GetValue(j)).ToList();
                    }
                }

                List <CredentialViewModel> filterRecord = null;
                if (predicate != null)
                {
                    filterRecord = itemRecord.ToList().FindAll(predicate);
                }
                else
                {
                    filterRecord = itemRecord.ToList();
                }

                paginatedList.Items = filterRecord.Skip(skip).Take(take).ToList();

                paginatedList.Completed   = itemsList.Completed;
                paginatedList.Impediments = itemsList.Impediments;
                paginatedList.PageNumber  = itemsList.PageNumber;
                paginatedList.PageSize    = itemsList.PageSize;
                paginatedList.ParentId    = itemsList.ParentId;
                paginatedList.Started     = itemsList.Started;
                paginatedList.TotalCount  = filterRecord?.Count;
            }

            return(paginatedList);
        }
Ejemplo n.º 24
0
        public PaginatedList <ScheduleViewModel> FindAllView(Predicate <ScheduleViewModel> predicate = null, string sortColumn = "", OrderByDirectionType direction = OrderByDirectionType.Ascending, int skip = 0, int take = 100)
        {
            PaginatedList <ScheduleViewModel> paginatedList = new PaginatedList <ScheduleViewModel>();

            var schedulesList = base.Find(null, j => j.IsDeleted == false);

            if (schedulesList != null && schedulesList.Items != null && schedulesList.Items.Count > 0)
            {
                var scheduleRecord = from s in schedulesList.Items
                                     join a in dbContext.Agents on s.AgentId equals a.Id into table1
                                     from a in table1.DefaultIfEmpty()
                                     join p in dbContext.Processes on s.ProcessId equals p.Id into table2
                                     from p in table2.DefaultIfEmpty()
                                     select new ScheduleViewModel
                {
                    Id             = s?.Id,
                    StartDate      = s?.StartDate,
                    ExpiryDate     = s?.ExpiryDate,
                    Name           = s?.Name,
                    StartingType   = s?.StartingType,
                    Status         = s?.Status,
                    AgentId        = (a == null || a.Id == null) ? Guid.Empty : a.Id.Value,
                    AgentName      = a?.Name,
                    ProcessId      = (p == null || p.Id == null) ? Guid.Empty : p.Id.Value,
                    ProcessName    = p?.Name,
                    CRONExpression = s?.CRONExpression,
                    IsDisabled     = s?.IsDisabled,
                    NextExecution  = s?.NextExecution,
                    LastExecution  = s?.LastExecution,
                    TriggerName    = s?.TriggerName,
                    ProjectId      = s?.ProjectId,
                    CreatedOn      = s?.CreatedOn,
                    CreatedBy      = s?.CreatedBy
                };

                if (!string.IsNullOrWhiteSpace(sortColumn))
                {
                    if (direction == OrderByDirectionType.Ascending)
                    {
                        scheduleRecord = scheduleRecord.OrderBy(s => s.GetType().GetProperty(sortColumn).GetValue(s)).ToList();
                    }
                    else if (direction == OrderByDirectionType.Descending)
                    {
                        scheduleRecord = scheduleRecord.OrderByDescending(s => s.GetType().GetProperty(sortColumn).GetValue(s)).ToList();
                    }
                }

                List <ScheduleViewModel> filterRecord = null;
                if (predicate != null)
                {
                    filterRecord = scheduleRecord.ToList().FindAll(predicate);
                }
                else
                {
                    filterRecord = scheduleRecord.ToList();
                }

                paginatedList.Items = filterRecord.Skip(skip).Take(take).ToList();

                paginatedList.Completed   = schedulesList.Completed;
                paginatedList.Impediments = schedulesList.Impediments;
                paginatedList.PageNumber  = schedulesList.PageNumber;
                paginatedList.PageSize    = schedulesList.PageSize;
                paginatedList.ParentId    = schedulesList.ParentId;
                paginatedList.Started     = schedulesList.Started;
                paginatedList.TotalCount  = filterRecord?.Count;
            }

            return(paginatedList);
        }
Ejemplo n.º 25
0
        public PaginatedList <AllJobsViewModel> FindAllView(Predicate <AllJobsViewModel> predicate = null, string sortColumn = "", OrderByDirectionType direction = OrderByDirectionType.Ascending, int skip = 0, int take = 100)
        {
            PaginatedList <AllJobsViewModel> paginatedList = new PaginatedList <AllJobsViewModel>();

            var jobsList = base.Find(null, j => j.IsDeleted == false);

            if (jobsList != null && jobsList.Items != null && jobsList.Items.Count > 0)
            {
                var jobRecord = from j in jobsList.Items
                                join a in dbContext.Agents on j.AgentId equals a.Id into table1
                                from a in table1.DefaultIfEmpty()
                                join p in dbContext.Automations on j.AutomationId equals p.Id into table2
                                from p in table2.DefaultIfEmpty()
                                join g in dbContext.AgentGroups on j.AgentGroupId equals g.Id into table3
                                from g in table3.DefaultIfEmpty()
                                select new AllJobsViewModel
                {
                    Id                          = j?.Id,
                    CreatedOn                   = j?.CreatedOn,
                    CreatedBy                   = j?.CreatedBy,
                    IsSuccessful                = j?.IsSuccessful,
                    Message                     = j?.Message,
                    JobStatus                   = j?.JobStatus,
                    AgentId                     = (a == null || a?.Id == null) ? Guid.Empty : a?.Id.Value,
                    AgentGroupId                = (g == null || g?.Id == null) ? Guid.Empty : g?.Id.Value,
                    AgentName                   = a?.Name,
                    AgentGroupName              = g?.Name,
                    AutomationId                = (p == null || p.Id == null) ? Guid.Empty : p.Id.Value,
                    AutomationName              = p?.Name,
                    StartTime                   = j.StartTime,
                    EndTime                     = j.EndTime,
                    EnqueueTime                 = j.EnqueueTime,
                    DequeueTime                 = j.DequeueTime,
                    AutomationVersion           = j.AutomationVersion,
                    AutomationVersionId         = j.AutomationVersionId,
                    AutomationExecutionLogCount = j.AutomationExecutionLogCount,
                    AutomationLogCount          = j.AutomationLogCount
                };

                if (!string.IsNullOrWhiteSpace(sortColumn))
                {
                    if (direction == OrderByDirectionType.Ascending)
                    {
                        jobRecord = jobRecord.OrderBy(j => j.GetType().GetProperty(sortColumn).GetValue(j)).ToList();
                    }
                    else if (direction == OrderByDirectionType.Descending)
                    {
                        jobRecord = jobRecord.OrderByDescending(j => j.GetType().GetProperty(sortColumn).GetValue(j)).ToList();
                    }
                }

                List <AllJobsViewModel> filterRecord = null;
                if (predicate != null)
                {
                    filterRecord = jobRecord.ToList().FindAll(predicate);
                }
                else
                {
                    filterRecord = jobRecord.ToList();
                }

                paginatedList.Items = filterRecord.Skip(skip).Take(take).ToList();

                paginatedList.Completed   = jobsList.Completed;
                paginatedList.Impediments = jobsList.Impediments;
                paginatedList.PageNumber  = jobsList.PageNumber;
                paginatedList.PageSize    = jobsList.PageSize;
                paginatedList.ParentId    = jobsList.ParentId;
                paginatedList.Started     = jobsList.Started;
                paginatedList.TotalCount  = filterRecord?.Count;//jobsList.TotalCount;
            }

            return(paginatedList);
        }
 public PaginatedList <AuditLogViewModel> GetAuditLogsView(Predicate <AuditLogViewModel> predicate = null, string sortColumn = "", OrderByDirectionType direction = OrderByDirectionType.Ascending, int skip = 0, int take = 100)
 {
     return(_repo.FindAllView(predicate, sortColumn, direction, skip, take));
 }
        public PaginatedList <AllAutomationsViewModel> FindAllView(Predicate <AllAutomationsViewModel> predicate = null, string sortColumn = "", OrderByDirectionType direction = OrderByDirectionType.Ascending, int skip = 0, int take = 100)
        {
            PaginatedList <AllAutomationsViewModel> paginatedList = new PaginatedList <AllAutomationsViewModel>();

            var itemsList = base.Find(null, j => j.IsDeleted == false);

            if (itemsList != null && itemsList.Items != null && itemsList.Items.Count > 0)
            {
                var itemRecord = from p in itemsList.Items
                                 join v in dbContext.AutomationVersions on p.Id equals v.AutomationId into table1
                                 from v in table1.DefaultIfEmpty()
                                 select new AllAutomationsViewModel
                {
                    Id            = p?.Id,
                    Name          = p?.Name,
                    CreatedOn     = p.CreatedOn,
                    CreatedBy     = p.CreatedBy,
                    Status        = v.Status,
                    VersionNumber = v.VersionNumber
                };

                if (!string.IsNullOrWhiteSpace(sortColumn))
                {
                    if (direction == OrderByDirectionType.Ascending)
                    {
                        itemRecord = itemRecord.OrderBy(j => j.GetType().GetProperty(sortColumn).GetValue(j)).ToList();
                    }
                    else if (direction == OrderByDirectionType.Descending)
                    {
                        itemRecord = itemRecord.OrderByDescending(j => j.GetType().GetProperty(sortColumn).GetValue(j)).ToList();
                    }
                }

                List <AllAutomationsViewModel> filterRecord = null;
                if (predicate != null)
                {
                    filterRecord = itemRecord.ToList().FindAll(predicate);
                }
                else
                {
                    filterRecord = itemRecord.ToList();
                }

                paginatedList.Items = filterRecord.Skip(skip).Take(take).ToList();

                paginatedList.Completed   = itemsList.Completed;
                paginatedList.Impediments = itemsList.Impediments;
                paginatedList.PageNumber  = itemsList.PageNumber;
                paginatedList.PageSize    = itemsList.PageSize;
                paginatedList.ParentId    = itemsList.ParentId;
                paginatedList.Started     = itemsList.Started;
                paginatedList.TotalCount  = filterRecord?.Count;
            }

            return(paginatedList);
        }