public async Task Get_given_right_guid_returns_Ok_with_items_from_service() { var calendarOptions = new CalendarOptions { Password = Guid.Parse("04a6c52fb35143799ef72f4f9a27d10c") }; var options = new Mock <IOptions <CalendarOptions> >(); options.SetupGet(o => o.Value).Returns(calendarOptions); var items = new Item[0]; var service = new Mock <ICalendarService>(); service.Setup(s => s.GetItemsAsync()).ReturnsAsync(items); var groupedByTitleAndTime = new Item[1]; var groupedByTitleAndStaff = new Item[2]; var converter = new Mock <ICalendarConverter>(); converter.Setup(c => c.GroupByTitleAndTime(items)).Returns(groupedByTitleAndTime); converter.Setup(c => c.GroupByTitleAndStaff(groupedByTitleAndTime)).Returns(groupedByTitleAndStaff); var controller = new CalendarController(options.Object, service.Object, converter.Object); var result = await controller.Get("04a6c52fb35143799ef72f4f9a27d10c") as OkObjectResult; Assert.Equal(groupedByTitleAndStaff, result.Value); }
public void Fill(CalendarOptions options) { this.Rows.Clear(); createGridHeader(); for (int i = 0; i < PluginsManager.Instance.Modules.Length; i++) { int newRowIndex = Rows.Count; Rows.Insert(newRowIndex); var row = Rows[newRowIndex]; var module = PluginsManager.Instance.Modules[i]; row.Tag = module.GlobalId; string text = EntryObjectLocalizationManager.Instance.GetString(module.EntryObjectType, LocalizationConstants.EntryObjectName); var cell = new SourceGrid.Cells.Cell(text); cell.Image = module.ModuleImage; this[newRowIndex, 0] = cell; bool isChecked = true; if (options.ShowIcons.ContainsKey(module.GlobalId)) { isChecked = options.ShowIcons[module.GlobalId]; } cell = new SourceGrid.Cells.CheckBox(null, isChecked); this[newRowIndex, 1] = cell; isChecked = options.GetDefaultEntry(module.GlobalId); cell = new SourceGrid.Cells.CheckBox(null, isChecked); this[newRowIndex, 2] = cell; } Columns.AutoSizeColumn(0); }
public CalendarService(IOptions <CalendarOptions> options, IRestClient client, ILogger <CalendarService> log) { this.options = options.Value; this.client = client; this.log = log; client.BaseUrl = new Uri(this.options.URL); }
void fillCalendarDayContents(CalendarOptions options) { ImageList imgList = new ImageList(); cmbTextFrom.Properties.SmallImages = imgList; cmbTextFrom.Properties.Items.Clear(); foreach (var dayContent in PluginsManager.Instance.CalendarDayContents) { imgList.Images.Add(dayContent.Image); ImageComboBoxItem item = new ImageComboBoxItem(dayContent.Name, dayContent.GlobalId, imgList.Images.Count - 1); cmbTextFrom.Properties.Items.Add(item); } if (cmbTextFrom.Properties.Items.Count > 0) { var item = cmbTextFrom.Properties.Items.GetItem(options.CalendarTextType); if (item != null) { cmbTextFrom.SelectedItem = item; } else { cmbTextFrom.SelectedIndex = 0; } } }
public async Task Get_new_sample() { var builder = new ConfigurationBuilder() .SetBasePath(Directory.GetCurrentDirectory()) .AddJsonFile("appsettings.json", optional: false, reloadOnChange: true) .AddJsonFile("local.settings.json", optional: true, reloadOnChange: true) .AddEnvironmentVariables(); var configuration = builder.Build(); var options = new CalendarOptions(); configuration.Bind("CalendarService", options); var calendarOptions = new Mock <IOptions <CalendarOptions> >(); calendarOptions.Setup(o => o.Value).Returns(options); var handler = new AuthorizedHandler(calendarOptions.Object); var service = new CalendarService(calendarOptions.Object, handler); var items = await service.GetItemsAsync(); var json = JsonSerializer.Serialize(items); File.WriteAllText($"../../../sample-{DateTime.UtcNow:yyyyMMddThhmmssZ}.json", json); }
public void Fill() { CalendarOptions options = UserContext.Settings.GuiState.CalendarOptions; pluginsGrid1.Fill(options); fillCalendarDayContents(options); chkShowRelativeDates.Checked = UserContext.Settings.GuiState.ShowRelativeDates; }
public CalendarController(IOptions <CalendarOptions> options, ICalendarService service, ICalendarConverter converter) { _options = options.Value; _service = service; _converter = converter; }
public void Fill() { CalendarOptions options = UserContext.Current.Settings.GuiState.CalendarOptions; fillModulesList(options); chkSaveGUI.IsChecked = UserContext.Current.Settings.GuiState.SaveGUI; chkShowRelativeDates.IsChecked = UserContext.Current.Settings.GuiState.ShowRelativeDates; chkSmartGridEdit.IsChecked = GuiState.Default.SmartEditingDataGrid; }
public CalendarService(IOptions <CalendarOptions> options) { _options = options.Value; // Thread safety: because the service is scoped, it might have to process multiple requests in parallel. // The cache needs to be able to deal with this. // See https://blog.stephencleary.com/2017/03/aspnetcore-synchronization-context.html _calendarCache = new ConcurrentDictionary <string, Calendar>(StringComparer.OrdinalIgnoreCase); _clients = new ConcurrentDictionary <string, CalendarClient>(StringComparer.OrdinalIgnoreCase); }
public CalendarViewModel( IOptions <CalendarOptions> options, IOptions <TimeZoneOptions> timezoneOptions, ICalendarManager calendarManager) { _options = options.Value; _timezoneOptions = timezoneOptions.Value; _calendarManager = calendarManager; }
public void Save() { CalendarOptions options = new CalendarOptions(); UserContext.Current.Settings.GuiState.ShowRelativeDates = chkShowRelativeDates.IsChecked.Value; saveList(options); UserContext.Current.Settings.GuiState.CalendarOptions = options; UserContext.Current.Settings.GuiState.SaveGUI = chkSaveGUI.IsChecked.Value; GuiState.Default.SmartEditingDataGrid = chkSmartGridEdit.IsChecked.Value; }
public CalendarService(IOptions <CalendarOptions> options, DelegatingHandler handler) { _options = options.Value; _client = new HttpClient(handler) { BaseAddress = _options.BaseAddress }; _client.DefaultRequestHeaders.Clear(); _client.DefaultRequestHeaders.Add("Accept", "application/json"); }
void saveList(CalendarOptions options) { options.DefaultEntries.Clear(); for (int index = 0; index < lvModulesSettings.Items.Count; index++) { ModuleSettingViewModel item = Modules[index]; //Guid moduleGlobalId = item.Value; //options.DefaultEntries[moduleGlobalId].IsDefault = item.IsDefault; item.Order = index; options.DefaultEntries.Add(item.Item); } }
public AuthorizedHandler(IOptions <CalendarOptions> options) { _options = options.Value; var cookie = new Cookie(_options.CookieName, _options.CookieValue, "/", _options.CookieDomain); var container = new CookieContainer(); container.Add(cookie); InnerHandler = new HttpClientHandler { CookieContainer = container }; }
public async Task Get_given_wrong_guid_returns_Unauthorized() { var calendarOptions = new CalendarOptions { Password = Guid.Parse("3905fb0e4b7349219b9c13334ea94250") }; var options = new Mock <IOptions <CalendarOptions> >(); options.SetupGet(o => o.Value).Returns(calendarOptions); var controller = new CalendarController(options.Object, null, null); var result = await controller.Get("04a6c52fb35143799ef72f4f9a27d10c"); Assert.IsType <UnauthorizedResult>(result); }
public void Save() { CalendarOptions options = new CalendarOptions(); if (cmbTextFrom.EditValue != null) { options.CalendarTextType = (Guid)cmbTextFrom.EditValue; } else { options.CalendarTextType = Guid.Empty; } UserContext.Settings.GuiState.ShowRelativeDates = chkShowRelativeDates.Checked; pluginsGrid1.Save(options); UserContext.Settings.GuiState.CalendarOptions = options; }
protected void _save_Click(object sender, EventArgs e) { // save values CalendarOptions options = new CalendarOptions(Server.MapPath(@"App_Data\LookupValues")); options.DefaultCalendarView = _defaultCalendarView.SelectedValue; options.ShowHistoryOnDayView = _showHistoryOnDayView.SelectedValue; options.ViewCalendarFor = UserList.SelectedValue; options.ShowOnActivities = _showOnActivities.SelectedValue; options.DayStart = _dayStart.SelectedItem.Text; // _dayStart.SelectedValue; options.DayEnd = _dayEnd.SelectedItem.Text; // _dayEnd.SelectedValue; options.DefaultInterval = _defaultInterval.SelectedValue; options.DefaultActivityType = ddlDefaultActivityType.SelectedValue; options.FirstDayOfTheWeek = _firstDayOfWeek.SelectedValue; options.Save(); }
public void Save(CalendarOptions options) { foreach (var gridViewRow in Rows) { if (gridViewRow.Tag == null) { continue; } Guid moduleGlobalId = (Guid)gridViewRow.Tag; CheckBox cell = (CheckBox)GetCell(gridViewRow.Index, 1); options.ShowIcons[moduleGlobalId] = cell.Checked.Value; cell = (CheckBox)GetCell(gridViewRow.Index, 2); options.DefaultEntries[moduleGlobalId] = cell.Checked.Value; } //foreach (ListViewItem item in lvImages.Items) //{ // options.ShowIcons.Add((Guid)item.Tag, item.Checked); //} }
protected void _save_Click(object sender, EventArgs e) { // save values CalendarOptions options = new CalendarOptions(Server.MapPath(@"App_Data\LookupValues")); options.DefaultCalendarView = _defaultCalendarView.SelectedValue; options.ShowHistoryOnDayView = _showHistoryOnDayView.SelectedValue; options.ViewCalendarFor = UserList.SelectedValue; options.ShowOnActivities = _showOnActivities.SelectedValue; options.DayStart = _dayStart.SelectedItem.Text; // _dayStart.SelectedValue; options.DayEnd = _dayEnd.SelectedItem.Text; // _dayEnd.SelectedValue; options.DefaultInterval = _defaultInterval.SelectedValue; options.DefaultActivityType = ddlDefaultActivityType.SelectedValue; options.Save(); }
protected void Page_PreRenderOld(object sender, EventArgs e) { CalendarOptions options; try { options = CalendarOptions.Load(Server.MapPath(@"App_Data\LookupValues")); } catch { // temporary, as the service throws an exception for options not found // the service is not yet complete, but this allows testing of the UI options = CalendarOptions.CreateNew(Server.MapPath(@"App_Data\LookupValues")); } // set user defaults Utility.SetSelectedValue(ddlDefaultCalendarView, options.DefaultCalendarView); Utility.SetSelectedValue(ddlNumberOfEvents, options.NumberOfEvents); Utility.SetSelectedValue(ddlShowHistoryOnDayView, options.ShowHistoryOnDayView); Utility.SetSelectedValue(ddlRememberSelectedUsers, options.RememberSelectedUsers); Utility.SetSelectedValue(ddlDisplayContactAccount, options.DisplayContactAccount); if (!string.IsNullOrEmpty(options.DayStart)) { DateTime timeHolder = DateTime.Parse(options.DayStart); ddlDayStart.ClearSelection(); ListItem startItem = ddlDayStart.Items.FindByValue(timeHolder.ToString("t")); if (startItem != null) { startItem.Selected = true; } else { startItem = ddlDayStart.Items.FindByText(timeHolder.ToString("t")); if (startItem != null) { startItem.Selected = true; } } } if (!string.IsNullOrEmpty(options.DayEnd)) { DateTime timeHolder = DateTime.Parse(options.DayEnd); ddlDayEnd.ClearSelection(); ListItem endItem = ddlDayEnd.Items.FindByValue(timeHolder.ToString("t")); if (endItem != null) { endItem.Selected = true; } else { endItem = ddlDayEnd.Items.FindByText(timeHolder.ToString("t")); if (endItem != null) { endItem.Selected = true; } } } chkOpportunity.Checked = options.ShowOpportunities; chkPhoneNumber.Checked = options.ShowPhoneNumber; chkRegarding.Checked = options.ShowRegarding; chkTime.Checked = options.ShowTime; chkMon.Checked = options.WorkWeekMon; chkTue.Checked = options.WorkWeekTue; chkWed.Checked = options.WorkWeekWed; chkThu.Checked = options.WorkWeekThu; chkFri.Checked = options.WorkWeekFri; chkSat.Checked = options.WorkWeekSat; chkSun.Checked = options.WorkWeekSun; Utility.SetSelectedValue(ddlDefaultInterval, options.DefaultInterval); Utility.SetSelectedValue(ddlDefaultActivityType, options.DefaultActivityType); Utility.SetSelectedValue(ddlFirstDayOfWeek, options.FirstDayOfWeek); Utility.SetSelectedValue(ddlFirstWeekOfYear, options.FirstWeekOfYear); }
protected void Page_Init(object sender, EventArgs e) { Options = new CalendarOptions(OptionsService); InitCalendar(); }
protected void Page_PreRender(object sender, EventArgs e) { CalendarOptions options = null; try { options = CalendarOptions.Load(Server.MapPath(@"App_Data\LookupValues")); } catch { // temporary, as the service throws an exception for options not found // the service is not yet complete, but this allows testing of the UI options = CalendarOptions.CreateNew(Server.MapPath(@"App_Data\LookupValues")); } _defaultCalendarView.DataSource = options.DefaultCalendarViewLookupList; _defaultCalendarView.DataTextField = options.DataTextField; _defaultCalendarView.DataValueField = options.DataValueField; _showHistoryOnDayView.DataSource = options.ShowHistoryOnDayViewLookupList; _showHistoryOnDayView.DataTextField = options.DataTextField; _showHistoryOnDayView.DataValueField = options.DataValueField; _showOnActivities.DataSource = options.ShowOnActivitiesLookupList; _showOnActivities.DataTextField = options.DataTextField; _showOnActivities.DataValueField = options.DataValueField; _dayStart.DataSource = options.DayStartLookupList; _dayStart.DataTextField = options.DataValueField; _dayStart.DataValueField = options.DataTextField; _dayEnd.DataSource = options.DayEndLookupList; _dayEnd.DataTextField = options.DataValueField; _dayEnd.DataValueField = options.DataTextField; _defaultInterval.DataSource = options.DefaultIntervalLookupList; _defaultInterval.DataTextField = options.DataValueField; _defaultInterval.DataValueField = options.DataValueField; _firstDayOfWeek.DataSource = LocalizeLookup("DayOfWeek", options.FistDayOfWeekList); _firstDayOfWeek.DataTextField = options.DataTextField; _firstDayOfWeek.DataValueField = options.DataValueField; DataBind(); BindUsers(); // set defaults Utility.SetSelectedValue(_defaultCalendarView, options.DefaultCalendarView); Utility.SetSelectedValue(_showHistoryOnDayView, options.ShowHistoryOnDayView); if (!Utility.SetSelectedValue(UserList, options.ViewCalendarFor)) { Utility.SetSelectedValue(UserList, ((SLXUserService)(ApplicationContext.Current.Services.Get <IUserService>())). GetUser().Id.ToString()); } Utility.SetSelectedValue(_showOnActivities, options.ShowOnActivities); if (!string.IsNullOrEmpty(options.DayStart)) { DateTime timeHolder = DateTime.Parse(options.DayStart); _dayStart.ClearSelection(); ListItem startItem = _dayStart.Items.FindByValue(timeHolder.ToString("t")); if (startItem != null) { startItem.Selected = true; } else { startItem = _dayStart.Items.FindByText(timeHolder.ToString("t")); if (startItem != null) { startItem.Selected = true; } } } if (!string.IsNullOrEmpty(options.DayEnd)) { DateTime timeHolder = DateTime.Parse(options.DayEnd); _dayEnd.ClearSelection(); ListItem endItem = _dayEnd.Items.FindByValue(timeHolder.ToString("t")); if (endItem != null) { endItem.Selected = true; } else { endItem = _dayEnd.Items.FindByText(timeHolder.ToString("t")); if (endItem != null) { endItem.Selected = true; } } } Utility.SetSelectedValue(_defaultInterval, options.DefaultInterval); Utility.SetSelectedValue(ddlDefaultActivityType, options.DefaultActivityType); Utility.SetSelectedValue(_firstDayOfWeek, options.FirstDayOfTheWeek); }
public Trigger(IOperableTrigger newTrigger, string schedulerInstanceName) { if (newTrigger == null) { return; } Name = newTrigger.Key.Name; Group = newTrigger.Key.Group; JobName = newTrigger.JobKey.Name; JobKey = $"{JobName}/{newTrigger.JobKey.Group}"; Scheduler = schedulerInstanceName; State = InternalTriggerState.Waiting; Description = newTrigger.Description; CalendarName = newTrigger.CalendarName; JobDataMap = newTrigger.JobDataMap.WrappedMap; FinalFireTimeUtc = newTrigger.FinalFireTimeUtc; MisfireInstruction = newTrigger.MisfireInstruction; Priority = newTrigger.Priority; HasMillisecondPrecision = newTrigger.HasMillisecondPrecision; FireInstanceId = newTrigger.FireInstanceId; EndTimeUtc = newTrigger.EndTimeUtc; StartTimeUtc = newTrigger.StartTimeUtc; NextFireTimeUtc = newTrigger.GetNextFireTimeUtc(); PreviousFireTimeUtc = newTrigger.GetPreviousFireTimeUtc(); if (NextFireTimeUtc != null) { NextFireTimeTicks = NextFireTimeUtc.Value.UtcTicks; } // Init trigger specific properties according to type of newTrigger. // If an option doesn't apply to the type of trigger it will stay null by default. switch (newTrigger) { case CronTriggerImpl cronTriggerImpl: Cron = new CronOptions { CronExpression = cronTriggerImpl.CronExpressionString, TimeZoneId = cronTriggerImpl.TimeZone.Id }; return; case SimpleTriggerImpl simpTriggerImpl: Simp = new SimpleOptions { RepeatCount = simpTriggerImpl.RepeatCount, RepeatInterval = simpTriggerImpl.RepeatInterval }; return; case CalendarIntervalTriggerImpl calTriggerImpl: Cal = new CalendarOptions { RepeatIntervalUnit = calTriggerImpl.RepeatIntervalUnit, RepeatInterval = calTriggerImpl.RepeatInterval, TimesTriggered = calTriggerImpl.TimesTriggered, TimeZoneId = calTriggerImpl.TimeZone.Id, PreserveHourOfDayAcrossDaylightSavings = calTriggerImpl.PreserveHourOfDayAcrossDaylightSavings, SkipDayIfHourDoesNotExist = calTriggerImpl.SkipDayIfHourDoesNotExist }; return; case DailyTimeIntervalTriggerImpl dayTriggerImpl: Day = new DailyTimeOptions { RepeatCount = dayTriggerImpl.RepeatCount, RepeatIntervalUnit = dayTriggerImpl.RepeatIntervalUnit, RepeatInterval = dayTriggerImpl.RepeatInterval, StartTimeOfDay = dayTriggerImpl.StartTimeOfDay, EndTimeOfDay = dayTriggerImpl.EndTimeOfDay, DaysOfWeek = dayTriggerImpl.DaysOfWeek, TimesTriggered = dayTriggerImpl.TimesTriggered, TimeZoneId = dayTriggerImpl.TimeZone.Id }; break; } }
void fillModulesList(CalendarOptions options) { //for (int i = 0; i < PluginsManager.Instance.EntryObjectExtensions.Length; i++) //{ // var module = PluginsManager.Instance.EntryObjectExtensions[i]; // var optionItem=options.DefaultEntries.Where(x => x.ModuleId == module.GlobalId).SingleOrDefault(); // if(optionItem!=null) // { // var item = new ModuleSettingViewModel(module,optionItem); // item.IsDefault = options.GetDefaultEntry(module.GlobalId); // lvModulesSettings.Items.Add(item); // } //} var temp = new ObservableCollection <ModuleSettingViewModel>(); for (int i = 0; i < PluginsManager.Instance.EntryObjectExtensions.Length; i++) { var module = PluginsManager.Instance.EntryObjectExtensions[i]; var optionItem = options.DefaultEntries.Where(x => x.ModuleId == module.GlobalId).SingleOrDefault(); if (optionItem == null) { optionItem = new CalendarOptionsItem(module.GlobalId, false); } ModuleSettingViewModel item = new ModuleSettingViewModel(optionItem); item.Value = module.GlobalId; item.Text = EntryObjectLocalizationManager.Instance.GetString(module.EntryObjectType, EnumLocalizer.EntryObjectName); item.Image = module.ModuleImage; item.IsDefault = options.GetDefaultEntry(module.GlobalId); item.CanBeDefault = canBeDefault(module.EntryObjectType); temp.Add(item); } for (int i = 0; i < PluginsManager.Instance.CalendarDayContentsEx.Count(); i++) { var module = PluginsManager.Instance.CalendarDayContentsEx.ElementAt(i); var optionItem = options.DefaultEntries.Where(x => x.ModuleId == module.Value.GlobalId).SingleOrDefault(); if (optionItem == null) { optionItem = new CalendarOptionsItem(module.Value.GlobalId, false); } ModuleSettingViewModel item = temp.Where(x => x.Value == module.Value.GlobalId).SingleOrDefault(); if (item == null) { item = new ModuleSettingViewModel(optionItem); item.Value = module.Value.GlobalId; item.Text = module.Value.Name; item.Image = module.Value.Image; item.CanBeDefault = false; temp.Add(item); } item.Order = options.DefaultEntries.IndexOf(optionItem); } Modules = new ObservableCollection <ModuleSettingViewModel>(temp.OrderBy(x => x.Order)); //foreach (var calendarOptionsItem in options.DefaultEntries) //{ // var module = PluginsManager.Instance.GetEntryObjectProvider(calendarOptionsItem.ModuleId); // var item = new ModuleSettingViewModel(module, calendarOptionsItem); // item.IsDefault = options.GetDefaultEntry(module.GlobalId); // lvModulesSettings.Items.Add(item); //} }