Exemplo n.º 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);
        }
Exemplo n.º 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));
            }
        }
Exemplo n.º 3
0
 public EntityAction(Enum entityType, EntityActionType entityActionType) :
     this(
         entityType : entityType,
         entityKey : null,
         entityActionTypes : new List <EntityActionType>() { entityActionType },
         entityActions : null
         )
 {
 }
Exemplo n.º 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);
        }
Exemplo n.º 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;
 }
Exemplo n.º 6
0
        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);
        }
Exemplo n.º 7
0
 public void Add(EntityActionType entityActionTypes)
 {
     _entityActionTypes.Add(entityActionTypes);
 }
Exemplo n.º 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
                                  ));
        }
Exemplo n.º 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
                                  ));
        }
Exemplo n.º 10
0
 public static Type TypeToClassType(EntityActionType type)
 {
     typeMap.TryGetValue(type, out Type classType);
     return(classType);
 }