Exemplo n.º 1
0
        public int QueryVendorDeviceCount(string filterText)
        {
            TableOperations <VendorDevice> tableOperations = DataContext.Table <VendorDevice>();
            RecordRestriction restriction = tableOperations.GetSearchRestriction(filterText);

            return(tableOperations.QueryRecordCount(restriction));
        }
Exemplo n.º 2
0
        public IEnumerable <VendorDevice> QueryVendorDevices(string sortField, bool ascending, int page, int pageSize, string filterText)
        {
            TableOperations <VendorDevice> tableOperations = DataContext.Table <VendorDevice>();
            RecordRestriction restriction = tableOperations.GetSearchRestriction(filterText);

            return(tableOperations.QueryRecords(sortField, ascending, page, pageSize, restriction));
        }
Exemplo n.º 3
0
        public int QueryMeasurementCount(string filterText)
        {
            TableOperations <Measurement> tableOperations = DataContext.Table <Measurement>();
            RecordRestriction             restriction     = tableOperations.GetSearchRestriction(filterText);

            return(tableOperations.QueryRecordCount(restriction));
        }
Exemplo n.º 4
0
        public int QueryCompanyCount(string filterText)
        {
            TableOperations <Company> tableOperations = DataContext.Table <Company>();
            RecordRestriction         restriction     = tableOperations.GetSearchRestriction(filterText);

            return(tableOperations.QueryRecordCount(restriction));
        }
Exemplo n.º 5
0
        private static RecordRestriction Combine(RecordRestriction left, RecordRestriction right, string operation)
        {
            // Check for null operands
            if ((object)left == null && (object)right == null)
            {
                return(null);
            }

            if ((object)left == null)
            {
                return(right);
            }

            if ((object)right == null)
            {
                return(left);
            }

            // Check for empty filter expressions
            bool leftEmpty  = string.IsNullOrWhiteSpace(left.FilterExpression);
            bool rightEmpty = string.IsNullOrWhiteSpace(right.FilterExpression);

            if (leftEmpty && rightEmpty)
            {
                return(null);
            }

            if (leftEmpty)
            {
                return(right);
            }

            if (rightEmpty)
            {
                return(left);
            }

            // Check for missing parameters
            int leftLength  = left.Parameters?.Length ?? 0;
            int rightLength = right.Parameters?.Length ?? 0;

            if (leftLength == 0 && rightLength == 0)
            {
                return(new RecordRestriction($"({left.FilterExpression}) {operation} ({right.FilterExpression})"));
            }

            object[] parameters = leftLength == 0 ? right.Parameters : (rightLength == 0 ? left.Parameters : left.Parameters.Combine(right.Parameters));

            object[] offsetArgs = Enumerable.Range(leftLength, rightLength).Select(index => (object)$"{{{index}}}").ToArray();

            return(new RecordRestriction($"({left.FilterExpression}) {operation} ({string.Format(right.FilterExpression, offsetArgs)})", parameters));
        }
Exemplo n.º 6
0
        public int QueryActiveMeasurementCount(string filterText)
        {
            TableOperations <ActiveMeasurement> tableOperations = DataContext.Table <ActiveMeasurement>();
            RecordRestriction restriction = tableOperations.GetSearchRestriction(filterText);

            if ((object)restriction == null)
            {
                restriction = new RecordRestriction("ID LIKE {0}", $"{GetSelectedInstanceName()}:%");
            }
            else
            {
                List <object> parameters = new List <object>(restriction.Parameters);
                parameters.Add($"{GetSelectedInstanceName()}:%");
                restriction = new RecordRestriction($"({restriction.FilterExpression}) AND ID LIKE {{{restriction.Parameters.Length}}}", parameters.ToArray());
            }

            return(tableOperations.QueryRecordCount(restriction));
        }
Exemplo n.º 7
0
        public IEnumerable <ActiveMeasurement> QueryActiveMeasurements(string sortField, bool ascending, int page, int pageSize, string filterText)
        {
            TableOperations <ActiveMeasurement> tableOperations = DataContext.Table <ActiveMeasurement>();
            RecordRestriction restriction = tableOperations.GetSearchRestriction(filterText);

            if ((object)restriction == null)
            {
                restriction = new RecordRestriction("ID LIKE {0}", $"{GetSelectedInstanceName()}:%");
            }
            else
            {
                List <object> parameters = new List <object>(restriction.Parameters);
                parameters.Add($"{GetSelectedInstanceName()}:%");
                restriction = new RecordRestriction($"({restriction.FilterExpression}) AND ID LIKE {{{restriction.Parameters.Length}}}", parameters.ToArray());
            }

            return(DataContext.Table <ActiveMeasurement>().QueryRecords(sortField, ascending, page, pageSize, restriction));
        }
Exemplo n.º 8
0
 /// <summary>
 /// Combines two record restrictions with an OR condition.
 /// </summary>
 /// <param name="left">Left operand.</param>
 /// <param name="right">Right operand.</param>
 /// <returns>New combined record restriction.</returns>
 /// <remarks>
 /// If both parameters are <c>null</c>, result will be <c>null</c>. If one parameter is <c>null</c>
 /// and the other parameter is not, the non-null parameter will be returned. Equally, if the
 /// <see cref="FilterExpression"/> of both parameters are <c>null</c>, empty or only whitespace,
 /// then the result will be <c>null</c>. If one parameter has a filter expression that is
 /// <c>null</c>, empty or whitespace and the other parameter's filter expression is defined, then
 /// the parameter that has a filter expression will be returned.
 /// </remarks>
 public static RecordRestriction CombineOr(RecordRestriction left, RecordRestriction right)
 {
     return(Combine(left, right, "OR"));
 }
Exemplo n.º 9
0
        // Static Methods

        /// <summary>
        /// Combines two record restrictions with an AND condition.
        /// </summary>
        /// <param name="left">Left operand.</param>
        /// <param name="right">Right operand.</param>
        /// <returns>New combined record restriction.</returns>
        /// <remarks>
        /// If both parameters are <c>null</c>, result will be <c>null</c>. If one parameter is <c>null</c>
        /// and the other parameter is not, the non-null parameter will be returned. Equally, if the
        /// <see cref="FilterExpression"/> of both parameters are <c>null</c>, empty or only whitespace,
        /// then the result will be <c>null</c>. If one parameter has a filter expression that is
        /// <c>null</c>, empty or whitespace and the other parameter's filter expression is defined, then
        /// the parameter that has a filter expression will be returned.
        /// </remarks>
        public static RecordRestriction CombineAnd(RecordRestriction left, RecordRestriction right)
        {
            return(Combine(left, right, "AND"));
        }
        private string GetHeaders(DataContext dataContext, IEnumerable<int> pointIDs)
        {
            object[] parameters = pointIDs.Cast<object>().ToArray();
            string parameterizedQueryString = $"PointID IN ({string.Join(",", parameters.Select((parameter, index) => $"{{{index}}}"))})";
            RecordRestriction pointIDRestriction = new RecordRestriction(parameterizedQueryString, parameters);

            return "\"Timestamp\"," + string.Join(",", dataContext.Table<Measurement>().
                QueryRecords(restriction: pointIDRestriction).
                Select(measurement => $"\"[{measurement.PointID}] {measurement.PointTag}\""));
        }