public override void EditRule(IDataRule aRule) { base.EditRule(aRule); chkConvertToString.Checked = aRule.ConvertToString; rbRandomDateTime.Checked = aRule.IsRandom; rbDateTimeInc.Checked = !aRule.IsRandom; string inc = String.Empty; int idx = -1; if (aRule.RuleType == FieldTypes.Time) { TimeRule tRule = (TimeRule)aRule; startDatePicker.Value = tRule.Start; endDatePicker.Value = tRule.End; idx = cboRate.Items.IndexOf(tRule.RateType.ToString()); inc = tRule.Increment.ToString(); } else { DateRule dRule = (DateRule)aRule; startDatePicker.Value = dRule.Start; endDatePicker.Value = dRule.End; idx = cboRate.Items.IndexOf(dRule.RateType.ToString()); inc = dRule.Increment.ToString(); } cboRate.SelectedIndex = idx; txtTimeDateIncrement.Text = inc; }
public void TimeRuleSelectChange(TimeRule rule) { if (rule != null) { LoadWeek(rule.Week); books = new ObservableCollection <Book>(rule.TimeBased.Select(o => o.Book)); } }
public int?Post([FromBody] TimeRule value) { if (timeRepo.Add(value)) { return(value.ID); } return(null); }
private void CreateTimeRule(int timeSeriesId, int timeRuleOrder, TimeRuleType timeRuleType, int instanceId) { var timeRule = new TimeRule(); timeRule.TimeSeriesId = timeSeriesId; timeRule.TimeRuleOrder = timeRuleOrder; timeRule.TimeRuleType = timeRuleType; timeRule.TimeRuleInstanceId = instanceId; m_dbAdapter.TimeRule.New(timeRule); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } TimeRule = await _context.TimeRule.FirstOrDefaultAsync(m => m.TimeRuleID == id); if (TimeRule == null) { return(NotFound()); } return(Page()); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } TimeRule = await _context.TimeRule.FindAsync(id); if (TimeRule != null) { _context.TimeRule.Remove(TimeRule); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
private IList <TimeRule> LoaderTimeRules(XmlNode node) { var timeRules = new List <TimeRule>(); foreach (XmlNode timeRuleNode in node.SelectSingleNode("./timeRules")?.ChildNodes) { var timeRule = new TimeRule() { StartTime = Convert.ToDateTime(timeRuleNode.Attributes["startTime"]?.InnerText), EndTime = Convert.ToDateTime(timeRuleNode.Attributes["endTime"]?.InnerText), Tick = TimeSpan.Parse(timeRuleNode.Attributes["tick"]?.InnerText) }; timeRules.Add(timeRule); } return(timeRules); }
public static void Buildrule(TimeRule aRule, DateTime start, DateTime end, String increment, String rateType) { try { aRule.Start = start; aRule.End = end; double result = Double.NegativeInfinity; if (double.TryParse(increment, out result)) { aRule.Increment = result; } else { throw new Exception(); } aRule.RateType = EnumPlus.ConvertString(typeof(DateTimeRateTypes), rateType); } catch (Exception e) { throw new Exception("Build time rule failed"); } }
public bool Put(int id, [FromBody] TimeRule value) { return(timeRepo.Update(value)); }
public TimeRule Get(int id) { TimeRule value = timeRepo.GetByID(id); return(value != null ? new TimeRule(value) : null); }
void Start() { TimeRuleCache = GetComponent <TimeRule>(); }
public static IDataRule InitializeBase(FieldTypes generalType, bool isRandom, String fieldName, String fieldDataType, bool convertToString) { IDataRule result = null; switch (generalType) { case FieldTypes.Date: result = new DateRule(); break; case FieldTypes.Time: result = new TimeRule(); break; case FieldTypes.GUID: result = new GuidRule(); break; case FieldTypes.Imported: //result = new break; case FieldTypes.MultiColumn: result = new MultiFieldDataSourceRule(); break; case FieldTypes.SingleColumn: result = new SingleFieldDataSourceRule(); break; case FieldTypes.Number: result = new NumberRule(); break; case FieldTypes.String: result = new StringRule(); break; case FieldTypes.Bool: result = new BoolRule(); break; case FieldTypes.Dynamic: case FieldTypes.Type: result = new TRule(); break; case FieldTypes.Enumerator: result = new EnumeratorRule(); break; case FieldTypes.MappedSource: result = new MappedSourceRule(); break; case FieldTypes.Collection: result = new CollectionRule(); break; case FieldTypes.Tuple: result = new TupleRule(); break; } result.ConvertToString = convertToString; result.FieldDataType = fieldDataType; result.FieldName = fieldName; result.IsRandom = isRandom; result.RuleType = generalType; return(result); }
public async void AddOrUpdate(int index, int?id, DateTime fromDate, DateTime toDate, object _fromHour, object _toHour, bool status) { TimeSpan fromHour, toHour; string week = WeekCount(); _fromHour = _fromHour ?? new TimeSpan(); _toHour = _toHour ?? new TimeSpan(); if (_fromHour.GetType().Equals(typeof(DateTime))) { fromHour = ((DateTime)_fromHour).TimeOfDay; } else { fromHour = (TimeSpan)_fromHour; } if (_toHour.GetType().Equals(typeof(DateTime))) { toHour = ((DateTime)_toHour).TimeOfDay; } else { toHour = (TimeSpan)_toHour; } if (fromDate.TimeOfDay > toDate.TimeOfDay) { message = "Khoảng ngày không hợp lệ!"; return; } if (fromHour > toHour) { message = "Khoảng giờ không hợp lệ!"; return; } if (id != null) { TimeRule value = new TimeRule(id, fromDate, toDate, fromHour, toHour, week, status); ObservableCollection <TimeBased> timebased = new ObservableCollection <TimeBased>(books .Select(o => new TimeBased((int)id, o.ID))); value.TimeBased = timebased; bool result = await timeRepo.Update((int)id, value); if (result) { value.TimeBased = new ObservableCollection <TimeBased>(books.Select(o => new TimeBased((int)id, o))); timeRules[index] = value; message = MessageHelper.Get("up"); } else { message = MessageHelper.Get("upErr"); } } else { TimeRule value = new TimeRule(null, fromDate, toDate, fromHour, toHour, week, status); if (books.Count > 0) { ObservableCollection <TimeBased> timebased = new ObservableCollection <TimeBased>(books .Select(o => new TimeBased(0, o.ID))); value.TimeBased = timebased; } id = await timeRepo.Add(value); if (id > 0) { value.ID = (int)id; ObservableCollection <TimeBased> timebased = new ObservableCollection <TimeBased>(books .Select(o => new TimeBased((int)id, o))); value.TimeBased = timebased; timeRules.Add(value); message = MessageHelper.Get("add"); } else { message = MessageHelper.Get("addErr"); } } }