コード例 #1
0
        public List <MicroApp> GetAll(string rowKey)
        {
            List <MicroApp> dEntList = new List <MicroApp>();
            MicroApp        dEnt     = null;

            TableQuery <MicroApp> rangeQuery = new TableQuery <MicroApp>().Where(
                TableQuery.CombineFilters(
                    TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, _partKey),
                    TableOperators.And,
                    TableQuery.GenerateFilterCondition("RowKey", QueryComparisons.Equal, rowKey)
                    )
                );

            foreach (MicroApp e in _table.ExecuteQuery(rangeQuery))
            {
                char[] delim = { ',' };

                dEnt        = new MicroApp();
                dEnt.RowKey = (e.RowKey == null) ? DEFAULT_STR_VALUE : e.RowKey;
                //dEnt.Id = (e.RowKey == null) ? "EMPTY" : e.RowKey;
                dEnt.Name = (e.Name == null) ? DEFAULT_STR_VALUE : e.Name;
                dEnt.Url  = (e.Url == null) ? DEFAULT_STR_VALUE : e.Url;
                if (dEnt.roles != null)
                {
                    dEnt.AllowedRoles = dEnt.roles.Split(delim);
                }
                dEnt.roles       = (e.roles == null) ? DEFAULT_STR_VALUE : e.roles;
                dEnt.Description = (e.Description == null) ? DEFAULT_STR_VALUE : e.Description;


                dEntList.Add(dEnt);
            }

            return(dEntList);
        }
コード例 #2
0
        public List <MicroApp> GetAllPending()
        {
            List <MicroApp> dEntList = new List <MicroApp>();
            MicroApp        dEnt;

            TableQuery <MicroApp> rangeQuery = new TableQuery <MicroApp>().Where(
                TableQuery.CombineFilters(
                    TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, _partKey),
                    TableOperators.And,
                    TableQuery.GenerateFilterCondition("IsApprovedToUse", QueryComparisons.Equal, "Pending")
                    )
                );

            foreach (MicroApp e in _table.ExecuteQuery(rangeQuery))
            {
                dEnt        = new MicroApp();
                dEnt.RowKey = (e.RowKey == null) ? "EMPTY" : e.RowKey;
                //dEnt.Id = (e.RowKey == null) ? "EMPTY" : e.RowKey;
                dEnt.Name = (e.Name == null) ? "EMPTY" : e.Name;



                dEntList.Add(dEnt);
            }

            return(dEntList);
        }
コード例 #3
0
        public MicroApp UpdateEntity(string rowKey, MicroApp device, string approvalStatus)
        {
            // Create a retrieve operation that takes a customer entity.
            TableOperation retrieveOperation = TableOperation.Retrieve <MicroApp>(_partKey, rowKey);

            //  Execute the operation.
            TableResult retrievedResult = _table.Execute(retrieveOperation);

            //Assign the result to a object.
            MicroApp updateEntity = (MicroApp)retrievedResult.Result;

            if (updateEntity != null && device != null)
            {
                //updateEntity.Id = device.Id;
                // updateEntity.ETag = device.ETag;
            }

            if (updateEntity != null && approvalStatus != null)
            {
                //updateEntity.IsApprovedToUse = approvalStatus;
            }

            if (updateEntity != null)
            {
                //Create the Replace TableOperation.
                TableOperation updateOperation = TableOperation.Replace(updateEntity);

                //  Execute the operation.
                _table.Execute(updateOperation);
            }

            return(updateEntity);
        }
コード例 #4
0
        public List <MicroApp> GetAllForRole(string role)
        {
            List <MicroApp> dEntList = new List <MicroApp>();
            MicroApp        dEnt;

            TableQuery <MicroApp> rangeQuery = new TableQuery <MicroApp>().Where(
                TableQuery.GenerateFilterCondition("PartitionKey", QueryComparisons.Equal, _partKey)
                );

            foreach (MicroApp e in _table.ExecuteQuery(rangeQuery))
            {
                char[] delim = { ',' };

                dEnt        = new MicroApp();
                dEnt.RowKey = (e.RowKey == null) ? DEFAULT_STR_VALUE : e.RowKey;
                //dEnt.Id = (e.RowKey == null) ? "EMPTY" : e.RowKey;
                dEnt.Name = (e.Name == null) ? DEFAULT_STR_VALUE : e.Name;
                dEnt.Url  = (e.Url == null) ? DEFAULT_STR_VALUE : e.Url;
                if (e.roles != null)
                {
                    e.roles           = e.roles.Replace(" ", "");
                    dEnt.AllowedRoles = e.roles.Split(delim);
                }
                dEnt.roles       = (e.roles == null) ? DEFAULT_STR_VALUE : e.roles;
                dEnt.Description = (e.Description == null) ? DEFAULT_STR_VALUE : e.Description;

                if (dEnt.roles.ToLower().IndexOf(role.ToLower()) >= 0)
                {
                    dEntList.Add(dEnt);
                }
            }

            return(dEntList);
        }
コード例 #5
0
        public void InsertMicroAppDetails(MicroApp device)
        {
            TableResult result;

            // Create the table if it doesn't exist.
            _table.CreateIfNotExists();
            try
            {
                // Create the TableOperation object that inserts the customer entity.
                _insertOperation = TableOperation.Insert(device);

                // Execute the insert operation.
                result = _table.Execute(_insertOperation);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }