using System.Collections.Generic; using System.Linq; using Neo.Afx.ComponentModel; namespace Neo.Afx.Admin.Integration { /// /// Afx admin database /// public class AfxAdminIntegrationDatabase : Database { /// /// Constructor /// public AfxAdminIntegrationDatabase() : base(new AfxAdminIntegrationContext(), 900000) { } #region GetConnections /// /// Get all data from table. /// /// List of objects public IEnumerable GetConnections() { return (from item in Context.Connections where !item.IsCancelled select item).ToList(); } /// /// Get data from table based on count. /// /// Restricts amount returned items in the collection. /// List of objects. public IEnumerable GetConnections(int count) { return (from item in Context.Connections where item.IsCancelled == false select item).Take(count).ToList(); } #endregion #region GetConnectionTypes /// /// Get all data from table. /// /// List of objects public IEnumerable GetConnectionTypes() { return (from item in Context.ConnectionTypes select item).ToList(); } /// /// Get data from table based on count. /// /// Restricts amount returned items in the collection. /// List of objects. public IEnumerable GetConnectionTypes(int count) { return (from item in Context.ConnectionTypes select item).Take(count).ToList(); } #endregion #region GetCommandTypes /// /// Get all data from table. /// /// List of objects public IEnumerable GetCommandTypes() { return (from item in Context.CommandTypes select item).ToList(); } /// /// Get data from table based on count. /// /// Restricts amount returned items in the collection. /// List of objects. public IEnumerable GetCommandTypes(int count) { return (from item in Context.CommandTypes select item).Take(count).ToList(); } #endregion #region GetDataSources /// /// Get all data from table. /// /// List of objects public IEnumerable GetDataSources() { return (from item in Context.DataSources select item).ToList(); } /// /// Get data from table based on count. /// /// Restricts amount returned items in the collection. /// List of objects. public IEnumerable GetDataSources(int count) { return (from item in Context.DataSources select item).Take(count).ToList(); } #endregion #region GetBulkReAssignMatrix /// /// Gets the bulk re assign matrix. /// /// The system ids. /// The user id. /// The workflow id. /// From user id. /// To user id. /// public IEnumerable GetBulkReAssignMatrix(string systemIds, long userId, long workflowId, long fromUserId, long toUserId) { return Context.Pr_SystemBulkReAssignMatrixGet(systemIds, userId, workflowId, fromUserId, toUserId).ToList(); } #endregion #region BulkReAssignTasksAndParticipants /// /// Bulks the re assign tasks and participants. /// /// The system ids. /// The workflow id. /// The workflow template step id. /// From user id. /// To user id. /// The comments. public void BulkReAssignTasksAndParticipants(string systemIds, long workflowId, long workflowTemplateStepId, long fromUserId, long toUserId, string comments) { Context.Pr_SystemBulkReAssignTasksAndParticipants(systemIds, workflowId, workflowTemplateStepId, fromUserId, toUserId, comments); } #endregion #region SearchSystemWorkflowInstances /// /// Searches the system workflow instances. /// /// The system ids. /// The searched by user id. /// The reference. /// if set to true [use minimum req fields only]. /// public IEnumerable SearchSystemWorkflowInstances(string systemIds, long searchedByUserId, string reference, bool useMinimumReqFieldsOnly) { if(useMinimumReqFieldsOnly) { return (from r in Context.Pr_SystemWorkflowInstanceSearcher(systemIds, searchedByUserId, reference) select new SystemWorkflowInstanceSearchRecord { WorkflowInstanceStatusID = r.WorkflowInstanceStatusID, WorkflowFriendlyName = r.WorkflowFriendlyName, ReferenceNumber = r.ReferenceNumber, ConsoleUrl = r.ConsoleUrl, WorkflowTemplateStep = r.WorkflowTemplateStep, WorkflowTemplateStepTitle = r.WorkflowTemplateStepTitle, WorkflowInstanceStatus = r.WorkflowInstanceStatus, IntegrationSystemID = r.IntegrationSystemID, WorkflowInstanceID = r.WorkflowInstanceID, IsWorkflowAdmin = r.IsWorkflowAdmin }).Distinct(new SystemWorkflowInstanceSearchRecordComparer()).ToList(); } else { return Context.Pr_SystemWorkflowInstanceSearcher(systemIds, searchedByUserId, reference).ToList(); } } public class SystemWorkflowInstanceSearchRecordComparer : IEqualityComparer { public new bool Equals(SystemWorkflowInstanceSearchRecord abc, SystemWorkflowInstanceSearchRecord def) { return abc.WorkflowInstanceID == def.WorkflowInstanceID; } public int GetHashCode(SystemWorkflowInstanceSearchRecord obj) { string code = obj.WorkflowInstanceID.ToString(); return code.GetHashCode(); } } #endregion #region CancelSystemWorkflowInstances /// /// Cancels the system workflow instances. /// /// The system id. /// The workflow instance id. /// The cancelled by user id. /// The comments. public void CancelSystemWorkflowInstances(long systemId, long workflowInstanceId, long cancelledByUserId, string comments) { Context.Pr_SystemWorkflowInstanceCancel(systemId.ToString(), workflowInstanceId, cancelledByUserId, comments); } #endregion } }