public IList <SystemActionDTO> GetByTypeAndGroupId(IUnitOfWork db,
                                                    SystemActionType type,
                                                    string groupId)
 {
     return(db.SystemActions.GetAllAsDto().Where(a => a.Type == (int)type &&
                                                 a.GroupId == groupId).ToList());
 }
 public IList <SystemActionDTO> GetByTypeAndTag(IUnitOfWork db,
                                                SystemActionType type,
                                                string tag)
 {
     return(db.SystemActions.GetAllAsDto().Where(a => a.Type == (int)type &&
                                                 a.Tag == tag).ToList());
 }
        public IList <SystemActionDTO> GetUnprocessedByType(IUnitOfWork db,
                                                            SystemActionType type,
                                                            DateTime?maxLastAttemptDate,
                                                            string tag)
        {
            var query = from a in db.SystemActions.GetAllAsDto()
                        join parent in db.SystemActions.GetAllAsDto() on a.ParentId equals parent.Id into withParent
                        from parent in withParent.DefaultIfEmpty()
                        where a.Status == (int)SystemActionStatus.None &&
                        a.Type == (int)type &&
                        (!a.ParentId.HasValue || parent.Status == (int)SystemActionStatus.Done)
                        orderby a.CreateDate ascending
                        select a;

            if (!String.IsNullOrEmpty(tag))
            {
                query = query.Where(a => a.Tag == tag);
            }
            else
            {
                if (maxLastAttemptDate.HasValue)
                {
                    query = query.Where(a => !a.AttemptDate.HasValue ||
                                        a.AttemptDate.Value <= maxLastAttemptDate);
                }
            }

            return(query.ToList());

            //return db.SystemActions.GetAllAsDto().Where(a => a.Type == (int)type
            //    && (a.Status == (int)SystemActionStatus.None
            //    //|| a.Status == (int)SystemActionStatus.Fail
            //    ))
            //    .OrderBy(act => act.CreateDate).ToList();
        }
        public long AddAction(IUnitOfWork db,
                              SystemActionType type,
                              string tag,
                              ISystemActionInput inputData,
                              long?parentActionId,
                              long?by,
                              SystemActionStatus?status = SystemActionStatus.None)
        {
            var input = JsonConvert.SerializeObject(inputData);

            _logService.Info("AddAction, type=" + type + ", inputData=" + input);
            var newAction = new SystemActionDTO()
            {
                ParentId  = parentActionId,
                Status    = (int)status,
                Type      = (int)type,
                Tag       = tag,
                InputData = input,

                CreateDate = _time.GetUtcTime(),
                CreatedBy  = by,
            };

            db.SystemActions.AddAction(newAction);

            return(newAction.Id);
        }
Exemple #5
0
 public static Packet NewSystemRequest(SystemActionType systemAction, string requestId, Payload payload = null)
 {
     return(new Packet
     {
         Type = PacketType.Request,
         SystemAction = systemAction,
         RequestId = requestId,
         Payload = payload,
     });
 }
        private SystemActionType GetSystemActionTypeID(string name)
        {
            SystemActionType result = SystemActionType.Custom;

            switch (name.ToLower().Trim())
            {
            case "description": result = SystemActionType.Description; break;

            case "resolution": result = SystemActionType.Resolution; break;

            case "email": result = SystemActionType.Email; break;

            default:
                break;
            }
            return(result);
        }
Exemple #7
0
        public void AddSystemAction(string actionGuid, SystemActionType actionType, string actionTitle, string controller, string action)
        {
            ValidateDuplication(Guid.Parse(actionGuid));

            string callingAssemblyName = Assembly.GetCallingAssembly().FullName;
            var module = Environment.LoadedModules.SingleOrDefault(
                m => m.AssemblyName == callingAssemblyName);

            var systemAction = new ModuleAction()
            {
                ActionGuid = Guid.Parse(actionGuid),
                ActionType = actionType,
                ActionTitle = actionTitle,
                Area = module == null ? string.Empty : FindConfigInModule(module).GetAreaName(),
                Controller = controller,
                Action = action,
                IsMenuItem = false,
                SystemModule = module
            };

            Environment.LoadedModuleActions.AddAction(systemAction);
        }
        public IList <SystemActionDTO> GetInProgressByType(IUnitOfWork db,
                                                           SystemActionType type,
                                                           DateTime?withAttemptDateAfterThis)
        {
            var query = from a in db.SystemActions.GetAllAsDto()
                        where a.Status == (int)SystemActionStatus.InProgress &&
                        a.Type == (int)type
                        select a;

            if (withAttemptDateAfterThis.HasValue)
            {
                query = query.Where(a => !a.AttemptDate.HasValue ||
                                    a.AttemptDate.Value >= withAttemptDateAfterThis);
            }

            return(query.ToList());

            //return db.SystemActions.GetAllAsDto().Where(a => a.Type == (int)type
            //    && (a.Status == (int)SystemActionStatus.None
            //    //|| a.Status == (int)SystemActionStatus.Fail
            //    ))
            //    .OrderBy(act => act.CreateDate).ToList();
        }
Exemple #9
0
 public static Packet NewSystemPacket(SystemActionType systemAction, Payload payload = null)
 => new Packet
 {
     Type = PacketType.Default, SystemAction = systemAction, Payload = payload
 };
        public bool IsExist(string tag, SystemActionType type)
        {
            var existItem = GetAllAsDto().FirstOrDefault(a => a.Tag == tag || a.Type == (int)type);

            return(existItem != null);
        }