예제 #1
0
        public List <HappyAlert> GetAll(string rowKey)
        {
            List <HappyAlert> dEntList = new List <HappyAlert>();
            HappyAlert        dEnt     = null;

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

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

                dEnt        = new HappyAlert();
                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.AlertMessage = (e.AlertMessage == null) ? DEFAULT_STR_VALUE : e.AlertMessage;
                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 <HappyAlert> GetAllForRole(string role)
        {
            List <HappyAlert> dEntList = new List <HappyAlert>();
            HappyAlert        dEnt;

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

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

                dEnt        = new HappyAlert();
                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.AlertMessage = (e.AlertMessage == null) ? DEFAULT_STR_VALUE : e.AlertMessage;
                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);
        }
예제 #3
0
        public void InsertHappyAlertDetails(HappyAlert 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;
            }
        }