Beispiel #1
0
 public static bool IsTimeRangeFilterEqual(TimeRangeFilter t1, TimeRangeFilter t2)
 {
     return
         ((t1.limit == t2.limit) &&
          (t1.offset == t2.offset) &&
          (t1.time[0] == t2.time[0]) &&
          (t1.time[1] == t2.time[1]) &&
          (t1.type == t2.type));
 }
Beispiel #2
0
        public static TimeRangeFilter GetTimeRangeFilter(DateTime from_, DateTime to, int limit, string type, string offset)
        {
            TimeRangeFilter _ft = new TimeRangeFilter();

            _ft.time    = new string[2];
            _ft.time[0] = DateTimeHelp.ToUniversalTime_ToISO8601(from_);
            _ft.time[1] = DateTimeHelp.ToUniversalTime_ToISO8601(to);
            _ft.limit   = limit;
            _ft.type    = type;
            _ft.offset  = offset;

            return(_ft);
        }
Beispiel #3
0
        private void SetUiUsingFilterString(FilterItem filterItem)
        {
            tbName.Text = filterItem.Name;

            string _filterString = filterItem.Filter;

            m_timeRangeFilter = null;
            m_timeStampFilter = null;

            //Hack
            try
            {
                JsonSerializerSettings _settings = new JsonSerializerSettings();
                _settings.MissingMemberHandling = MissingMemberHandling.Error;
                m_timeRangeFilter = JsonConvert.DeserializeObject <TimeRangeFilter>(_filterString, _settings);

                rbTimeRange.Checked = true;

                datePicker_TR_From.Value = DateTimeHelp.ISO8601ToDateTime(m_timeRangeFilter.time[0]);
                datePicker_TR_To.Value   = DateTimeHelp.ISO8601ToDateTime(m_timeRangeFilter.time[1]);
                cmbType.SelectedIndex    = getIndexFromTypeString(m_timeRangeFilter.type);
            }
            catch
            {
                try
                {
                    m_timeStampFilter = JsonConvert.DeserializeObject <TimeStampFilter>(_filterString);

                    rbTimeStamp.Checked = true;

                    comboBox_TS_PN.SelectedIndex = (m_timeStampFilter.limit < 0) ? 0 : 1;
                    datePicker_TS_Time.Value     = DateTimeHelp.ISO8601ToDateTime(m_timeStampFilter.timestamp);
                    numericUpDown_TS_Limit.Value = Math.Abs(m_timeStampFilter.limit);
                    cmbType.SelectedIndex        = getIndexFromTypeString(m_timeStampFilter.type);
                }
                catch
                {
                }
            }
        }
Beispiel #4
0
        private void Reset()
        {
            m_isAddMode = true;

            m_currentFilterItem = null;

            m_timeRangeFilter = null;
            m_timeStampFilter = null;

            btnSaveUpdate.Text = "Save";
            Text = "Filter Manager [New]";

            rbTimeRange.Checked          = true;
            tbName.Text                  = "";
            cmbType.SelectedIndex        = 0;
            datePicker_TR_From.Value     = DateTime.Today;
            datePicker_TR_To.Value       = DateTime.Today;
            comboBox_TS_PN.SelectedIndex = 0;
            datePicker_TS_Time.Value     = DateTime.Today;
            numericUpDown_TS_Limit.Value = 20;

            tbName.Focus();
        }
Beispiel #5
0
        public static string GetTimeRangeFilterJson(DateTime from_, DateTime to, int limit, string type, string offset)
        {
            TimeRangeFilter _ft = GetTimeRangeFilter(from_, to, limit, type, offset);

            return(JsonConvert.SerializeObject(_ft));
        }
Beispiel #6
0
 public static string GetTimeRangeFilterJson(TimeRangeFilter timeRangeFilter)
 {
     return(JsonConvert.SerializeObject(timeRangeFilter));
 }