//public long AddAction(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,
        //    };
        //    using (var db = _dbFactory.GetRWDb())
        //    {
        //        db.SystemActions.AddAction(newAction);
        //        db.Commit();
        //    }

        //    return newAction.Id;
        //}

        public void SetResult(IUnitOfWork db,
                              long actionId,
                              SystemActionStatus status,
                              ISystemActionOutput outputData,
                              string groupId = null)
        {
            string output = null;

            if (outputData != null)
            {
                output = JsonConvert.SerializeObject(outputData);
            }

            _logService.Info("SetResult, actionId=" + actionId
                             + " status=" + status
                             + ", outputData=" + output
                             + ", groupId=" + groupId);

            var action = db.SystemActions.Get(actionId);

            if (action != null)
            {
                if (groupId != null)
                {
                    action.GroupId = groupId;
                }
                action.Status      = (int)status;
                action.OutputData  = output;
                action.AttemptDate = _time.GetUtcTime();
                if (status != SystemActionStatus.InProgress)
                {
                    action.AttemptNumber++;
                }
            }
        }
Ejemplo n.º 2
0
        public static string ToStr(ISystemActionOutput data)
        {
            if (data == null)
            {
                return(null);
            }

            return(JsonConvert.SerializeObject(data));
        }