Example #1
0
        public Task(string title, int workProgressPercent, DateTime startDate, DateTime startTime, DateTime endTime, TaskCategory category, EntityActionType entityActionType, Guid syncId, bool syncedWithServer)
        {

            setProperties(title, workProgressPercent, startDate, startTime, endTime, category, entityActionType);
            setSyncStatus(syncedWithServer);
            setSyncId(syncId);
        }
Example #2
0
        public static void Add(this List <Link> links, string rel, string href, EntityActionType entityAction)
        {
            switch (entityAction)
            {
            case EntityActionType.ReferenceEntity:
                links.AddReferenceEntity(rel, href);
                break;

            case EntityActionType.Entity:
                //links.AddEntity(rel, href, HttpMethodType.OPTIONS);
                links.AddEntity(rel, href);
                break;

            case EntityActionType.EntitySearch:
                //links.AddEntity(rel, href.Replace("/search", ""), HttpMethodType.OPTIONS);
                links.AddEntity(rel, href, HttpMethodType.POST);
                break;

            case EntityActionType.RelatedEntity:
                //links.AddRelatedEntity(rel, href, HttpMethodType.OPTIONS);
                links.AddRelatedEntity(rel, href);
                break;

            case EntityActionType.SubEntity:
                //links.AddSubEntity(rel, href, HttpMethodType.OPTIONS);
                links.AddSubEntity(rel, href);
                break;

            case EntityActionType.SubEntitySearch:
                //links.AddSubEntity(rel, href.Replace("/search", ""), HttpMethodType.OPTIONS);
                links.AddSubEntity(rel, href, HttpMethodType.POST);
                break;

            case EntityActionType.Action_Add:
                links.AddAction(rel, href, HttpMethodType.POST);
                links.AddAction(rel, href, HttpMethodType.OPTIONS);     // TODO: This line should be removed and the options on all the other gets should be uncommented
                break;

            case EntityActionType.Action_Update:
                links.AddAction(rel, href, HttpMethodType.PUT);
                break;

            case EntityActionType.Action_Partial_Update:
                links.AddAction(rel, href, HttpMethodType.PATCH);
                break;

            case EntityActionType.Action_Delete:
                links.AddAction(rel, href, HttpMethodType.DELETE);
                break;

            case EntityActionType.Action_Clone:
                links.AddAction(rel, href + "/clone", HttpMethodType.POST);
                break;

            default:
                throw new Exception(string.Format("Unhandled Entity Action Type '{0}'", rel));
            }
        }
Example #3
0
 public EntityAction(Enum entityType, EntityActionType entityActionType) :
     this(
         entityType : entityType,
         entityKey : null,
         entityActionTypes : new List <EntityActionType>() { entityActionType },
         entityActions : null
         )
 {
 }
Example #4
0
        public int JumpBoost;             //Varint

        public override void Read(byte[] array)
        {
            _ = McVarint.TryParse(ref array, out EntityID);
            if (McVarint.TryParse(ref array, out var actionID))
            {
                ActionID = (EntityActionType)actionID;
            }
            _ = McVarint.TryParse(ref array, out JumpBoost);
        }
Example #5
0
 private void setProperties(string title, int workProgressPercent, DateTime startDate, DateTime startTime, DateTime endTime, TaskCategory category, EntityActionType entityActionType)
 {
     this.WorkProgressPercent = workProgressPercent;
     this.StartDate = startDate;
     this.StartTime = startTime;
     this.EndTime = endTime;
     this.Title = title;
     this.Category = category;
     this.SyncedWithServer = false;
     this.ActionType = entityActionType;
 }
        public bool IsAuthorized(int userId, int entityId, EntityActionType actionType, EntityType entityType)
        {
            IUserAuthData        user  = _auth.GetCurrentUser();
            IEnumerable <string> roles = user.Roles;
            bool?isAdmin = roles?.Contains("SysAdmin");

            if (isAdmin.HasValue && isAdmin.Value)
            {
                return(true);
            }

            bool   hasAccess = false;
            string proc      = "dbo.Security_" + entityType + "_Can" + actionType;

            _dataProvider.ExecuteNonQuery
            (
                proc,
                inputParamMapper : delegate(SqlParameterCollection paramCol)
            {
                SqlParameter p  = new SqlParameter();
                p.ParameterName = "@HasAccess";
                p.SqlDbType     = SqlDbType.Bit;
                p.Direction     = ParameterDirection.Output;
                paramCol.Add(p);

                paramCol.AddWithValue("@userId", userId);
                paramCol.AddWithValue("@EntityId", entityId);
            },
                returnParameters : delegate(SqlParameterCollection paramCol)
            {
                Boolean.TryParse(paramCol["@HasAccess"].Value.ToString(), out hasAccess);
            }
            );

            return(hasAccess);
        }
Example #7
0
 public void Add(EntityActionType entityActionTypes)
 {
     _entityActionTypes.Add(entityActionTypes);
 }
Example #8
0
        public static void Add(this IList <EntityAction> entityActions, Enum entityType, long?id, EntityActionType actionType)
        {
            List <EntityActionType> entityActionTypes = new List <EntityActionType>()
            {
                actionType
            };

            entityActions.Add(new EntityAction(
                                  entityType: entityType,
                                  entityId: id,
                                  entityActionTypes: entityActionTypes
                                  ));
        }
Example #9
0
        public static void Add(this IList <EntityAction> entityActions, Enum entityType, string key, EntityActionType actionType)
        {
            List <EntityActionType> entityActionTypes = new List <EntityActionType>()
            {
                actionType
            };

            entityActions.Add(new EntityAction(
                                  entityType: entityType,
                                  entityKey: key,
                                  entityActionTypes: entityActionTypes
                                  ));
        }
Example #10
0
 public static Type TypeToClassType(EntityActionType type)
 {
     typeMap.TryGetValue(type, out Type classType);
     return(classType);
 }