public ActionResult AddNews() { var recents = dbContext.Recents.ToList(); List <Recent> items = new List <Recent>(); for (int i = 0; i < 4; i++) { Recent cacheitem = new Recent(); cacheitem.Time = DateTime.MinValue; if (recents.Count == 0) { break; } foreach (var item in recents) { if (item.Time > cacheitem.Time) { cacheitem = item; } } if (cacheitem.Time != DateTime.MinValue) { if (i > 2) { items.Add(cacheitem); } recents.Remove(cacheitem); } } return(PartialView(items)); }
protected override async void OnActivate() { await Recent.Initialize(); var firstRun = settings.Get <bool>("FirstRun").GetOrElse(true); if (!firstRun) { return; } var toast = new ToastPrompt { Title = "First run", TextOrientation = Orientation.Horizontal, Message = "Please check the 'Help' section. Tap here if you want to go there now", TextWrapping = TextWrapping.Wrap }; toast.Completed += (sender, args) => { if (args.PopUpResult == PopUpResult.Ok) { navigationService.UriFor <HelpPageViewModel>().Navigate(); } }; toast.Show(); settings.Set("FirstRun", false); }
public ActionResult News(int Id = 9999) { if (Id != 9999) { var news = dbContext.Recents.ToList(); foreach (var recent in news) { if (recent.Id == Id) { return(View("ThisNews", recent)); } } } HttpCookie cookie = Request.Cookies["Account"]; Account account = new Account(); if (cookie != null) { if (repository.SignIn(cookie["Email"], cookie["Password"], out string message1) != null) { account = repository.SignIn(cookie["Email"], cookie["Password"], out string message); ViewBag.Login = account.Login; } else { HttpCookie cookie2 = new HttpCookie("Account"); cookie2.Expires = DateTime.Now.AddDays(-1); Response.Cookies.Add(cookie2); } } var recents = dbContext.Recents.ToList(); List <Recent> items = new List <Recent>(); for (int i = 0; i < 8; i++) { Recent cacheitem = new Recent(); cacheitem.Time = DateTime.MinValue; foreach (var item in recents) { if (item.Time > cacheitem.Time) { cacheitem = item; } } if (cacheitem.Time != DateTime.MinValue) { items.Add(cacheitem); recents.Remove(cacheitem); } } if (items.Count == 0) { return(View()); } RecentComparer RC = new RecentComparer(); items.Sort(RC); return(View(items)); }
public ActionResult Create(string Caption, string Text, string FullText, byte[] LinkToSmallImage, byte[] LinkToLargeImage, string Author) { if (!(String.IsNullOrEmpty(Caption) && String.IsNullOrEmpty(Text) && String.IsNullOrEmpty(FullText) && String.IsNullOrEmpty(Author) && LinkToSmallImage == null)) { Recent recent = new Recent() { Author = Author, Caption = Caption, Text = Text, FullText = FullText, LinkSmallImg = LinkToSmallImage, LinkLargeImg = LinkToLargeImage, }; recent.Time = DateTime.Now; try { dbContext.Recents.Add(recent); dbContext.SaveChanges(); string ok = "Ok"; return(PartialView(ok)); } catch { return(PartialView("Error")); } } string mess = "Не все поля были заполнены"; return(PartialView(mess)); }
public void ClearRecent() { Recent.Clear(); NotifyOfPropertyChange(() => ShowRecent); DeleteRecentAsync(); }
public void SetAutoPopulateState() { if (this.inMemoryApplicationSettingModel.GetSetting(ApplicationSetting.AllowLocation).Value&& this.inMemoryApplicationSettingModel.GetSetting(ApplicationSetting.AutoPopulateLocation).Value) { SetAsCurrentLocation(); } else if (this.inMemoryApplicationSettingModel.GetSetting(ApplicationSetting.AutoPopulateMostRecent).Value) { Recent mostRecentTrip = unitOfWork.RecentTripRepository.GetMostRecent(); if (mostRecentTrip != null) { RecentTripMessage.Send(mostRecentTrip, RecentTripMessageReason.SetAsWhereToDestination); } else { this.TextLocation = AppResources.WhereToLocationTextBoxWaterMark; } } else if (this.inMemoryApplicationSettingModel.GetSetting(ApplicationSetting.AutoPopulateMostFrequent).Value) { Recent mostFrequentTrip = unitOfWork.RecentTripRepository.GetMostFrequent(); if (mostFrequentTrip != null) { RecentTripMessage.Send(mostFrequentTrip, RecentTripMessageReason.SetAsWhereToDestination); } else { this.TextLocation = AppResources.WhereToLocationTextBoxWaterMark; } } }
public override void OnNavigatingTo(NavigationParameters parameters) { switch (StaticObject.MasterSelected) { case eMasterSelected.Category: Category = (Category)parameters["model"]; Title = Category.Name.ToString(); break; case eMasterSelected.Source: Source = (Source)parameters["model"]; Title = Source.Name; break; case eMasterSelected.Country: Country = (Country)parameters["model"]; Title = Source.Name; break; case eMasterSelected.Favorite: SourceRealm = (SourceRealm)parameters["model"]; Title = SourceRealm.Name; break; case eMasterSelected.Recent: RecentSource = (Recent)parameters["model"]; Title = RecentSource.Name; break; } }
public void AddRecent(Server server) { var recentServer = new RecentServer(server); Recent.AddLocked(recentServer); server.LastJoinedOn = null; SaveSettings(); }
public void OnGet() { var sessionAddress = HttpContext.Session.GetString("SessionAddress"); if (sessionAddress != null) { Legion = JsonConvert.DeserializeObject <Recent>(sessionAddress); } }
public DynamicJsonValue ToJson() { return(new DynamicJsonValue { [nameof(DatabasePerformanceMetrics.MetricType)] = MeterType, [nameof(Recent)] = new DynamicJsonArray(Recent.Select(x => x.ToJson())), [nameof(History)] = new DynamicJsonArray(History.Select(x => x.ToJson())) }); }
public void ForwardInAnimationComplete() { Telegram.Api.Helpers.Execute.BeginOnThreadPool(() => { _recentResults = _recentResults ?? TLUtils.OpenObjectFromMTProtoFile <TLVector <TLResultInfo> >(_recentSyncRoot, Constants.RecentSearchResultsFileName) ?? new TLVector <TLResultInfo>(); var recent = new List <TLObject>(); foreach (var result in _recentResults) { if (result.Type.ToString() == "user") { var user = _cacheService.GetUser(result.Id); if (user != null) { recent.Add(user); if (user.Dialog == null) { user.Dialog = _cacheService.GetDialog(new TLPeerUser { Id = user.Id }); } } } if (result.Type.ToString() == "chat") { var chat = _cacheService.GetChat(result.Id); if (chat != null) { recent.Add(chat); if (chat.Dialog == null) { chat.Dialog = _cacheService.GetDialog(new TLPeerChat { Id = chat.Id }); } } } } Telegram.Api.Helpers.Execute.BeginOnUIThread(() => { if (!string.IsNullOrEmpty(Text)) { return; } Recent.Clear(); foreach (var recentItem in recent) { Recent.Add(recentItem); } NotifyOfPropertyChange(() => ShowRecent); }); }); }
public DynamicJsonValue ToJson() { return(new DynamicJsonValue { [nameof(File)] = File, [nameof(Status)] = Status, [nameof(Recent)] = new DynamicJsonArray(Recent.Select(x => x.ToJson())), [nameof(History)] = new DynamicJsonArray(History.Select(x => x.ToJson())) }); }
private void HandleVoiceCommands() { if (NavigationContext.QueryString.ContainsKey("VoiceCommand")) { string voiceCommand = NavigationContext.QueryString["VoiceCommand"]; switch (voiceCommand) { case "Record": NavigationService.Navigate(ViewLocator.View("Record")); break; case "Show": if (NavigationContext.QueryString.ContainsKey("views")) { string view = NavigationContext.QueryString["views"]; switch (view) { case "all": NavigationService.Navigate(ViewLocator.View("List")); break; case "favorites": NavigationService.Navigate(ViewLocator.View("Favorites")); break; case "map": NavigationService.Navigate(ViewLocator.View("ListMap")); break; } } break; case "Play": if (NavigationContext.QueryString.ContainsKey("plays")) { var plays = NavigationContext.QueryString["plays"]; switch (plays) { case "last recorded": var memo = Recent.FirstOrDefault(); if (memo != null) { NavigationService.Navigate(ViewLocator.View("Memo", new { Id = memo.Id, Action = "Play" })); } break; } } break; } } }
public void ClearRecent() { Recent.Clear(); NotifyOfPropertyChange(() => ShowRecent); Telegram.Api.Helpers.Execute.BeginOnThreadPool(() => { var recentResults = new TLVector <TLResultInfo>(); _recentResults = recentResults; TLUtils.SaveObjectToMTProtoFile(_recentSyncRoot, Constants.RecentSearchResultsFileName, recentResults); }); }
public void AddRecentFile(string FileName) { if (string.IsNullOrWhiteSpace(FileName)) { return; } while (Recent.Contains(FileName)) { Recent.Remove(FileName); } Recent = Recent.Take(9).ToList(); Recent.Insert(0, FileName); }
protected void Page_Load(object sender, EventArgs e) { if (Page.IsPostBack && Request.Form["rect"] != null && Request.Form["recid"] != null) { GotoRecent(int.Parse(Request.Form["recid"]), int.Parse(Request.Form["rect"])); } this.ID = "RecentItems"; this.Title = Core.Root.rm.GetString("Recent"); UserConfig UC = (UserConfig)HttpContext.Current.Session["UserConfig"]; DataTable dt = Recent.LoadRecentItems(UC.UserId); recentLbl.Text = RenderList(dt); }
//returns all logs in reverse chronological order as per their dates. // Flag enum givens us how much of the past logs we want to see public IQueryable <SystemLog> GetLogs(Recent flag) { if (flag == Recent.Last_7_Days) { return(context.SystemLogs.OrderByDescending(x => x.Id).Where(x => new TimeSpan((DateTime.Now - x.Date).Ticks).Minutes <= 10080)); } else if (flag == Recent.Last_30_Days) { return(context.SystemLogs.OrderByDescending(x => x.Id).Where(x => new TimeSpan((DateTime.Now - x.Date).Ticks).Minutes <= 43200)); } else { return(context.SystemLogs.OrderByDescending(x => x.Id)); } }
protected override void OnNavigatedTo(System.Windows.Navigation.NavigationEventArgs e) { base.OnNavigatedTo(e); string id; if (NavigationContext.QueryString.TryGetValue("favouriteId", out id)) { if (!String.IsNullOrEmpty(id)) { IUnitOfWork unitOfWork = SimpleIoc.Default.GetInstance <IUnitOfWork>(); Favourite favourite = unitOfWork.FavouriteRepository.GetById(Guid.Parse(id)); FavouriteMessage.Send(favourite, DrumbleApp.Shared.Messages.Enums.FavouriteMessageReason.SetAsWhereTo); } } else if (NavigationContext.QueryString.TryGetValue("recentTripId", out id)) { if (!String.IsNullOrEmpty(id)) { IUnitOfWork unitOfWork = SimpleIoc.Default.GetInstance <IUnitOfWork>(); Recent recentTrip = unitOfWork.RecentTripRepository.GetById(Guid.Parse(id)); RecentTripMessage.Send(recentTrip, DrumbleApp.Shared.Messages.Enums.RecentTripMessageReason.SetAsWhereToDestination); } } if (NavigationContext.QueryString.TryGetValue("userId", out id)) { if (!String.IsNullOrEmpty(id)) { #if !DEBUG FlurryWP8SDK.Api.SetUserId(id); #endif } } #if !DEBUG FlurryWP8SDK.Api.LogPageView(); #endif NavigationContext.QueryString.Clear(); }
public static void SelectLogFile(string fileName) { Program.LogFileName = fileName; ReloadRecent(); Recent.RemoveAll(r => string.Equals(r, fileName, StringComparison.InvariantCultureIgnoreCase)); Recent.Insert(0, fileName); if (Recent.Count > 20) { Recent.RemoveAt(20); } Properties.Settings.Default.Filename = Program.LogFileName; Properties.Settings.Default.Recent = Recent.ToArray(); Properties.Settings.Default.Save(); }
public void highlightsubmenue(int navsubframekey) { DoubleAnimation opaout = new DoubleAnimation() { From = 1, To = 0, Duration = TimeSpan.FromMilliseconds(500) }; DoubleAnimation opain = new DoubleAnimation() { From = 0, To = 1, Duration = TimeSpan.FromMilliseconds(500) }; Debug.Print("Aminations built for Navigation Highlighter"); switch (navsubframekey) //mainframekey: 1 is ziel, 2 is letzte ziele, 3 is POI, 4 is MapTanken { case 1: //Ziel Address.BeginAnimation(DropShadowEffect.OpacityProperty, opain); if (FuelMap.Opacity == 0) { FuelMap.BeginAnimation(DropShadowEffect.OpacityProperty, opaout); Debug.Print("nav highlighter if 1 called"); } if (Recent.Opacity == 1) { Recent.BeginAnimation(DropShadowEffect.OpacityProperty, opaout); Debug.Print("nav highligther if 2 called"); } Debug.Print("Case 1 called"); break; case 2: //Recent Recent.BeginAnimation(DropShadowEffect.OpacityProperty, opain); if (Address.Opacity == 1) { Address.BeginAnimation(DropShadowEffect.OpacityProperty, opaout); } if (POI.Opacity == 0) { POI.BeginAnimation(DropShadowEffect.OpacityProperty, opaout); } Debug.Print("Case 2 called"); break; case 3: //POI POI.BeginAnimation(DropShadowEffect.OpacityProperty, opain); if (Recent.Opacity == 0) { Recent.BeginAnimation(DropShadowEffect.OpacityProperty, opaout); } if (FuelMap.Opacity == 0) { FuelMap.BeginAnimation(DropShadowEffect.OpacityProperty, opaout); } Debug.Print("Case 3 called"); break; case 4: //FuelMap FuelMap.BeginAnimation(DropShadowEffect.OpacityProperty, opain); if (POI.Opacity == 0) { POI.BeginAnimation(DropShadowEffect.OpacityProperty, opaout); } if (Address.Opacity == 0) { Address.BeginAnimation(DropShadowEffect.OpacityProperty, opaout); } Debug.Print("Case 4 called"); break; default: Debug.Print("Default called"); break; } }
public static void Send(Recent recentTrip, RecentTripMessageReason reason) { new RecentTripMessage(recentTrip, reason).Send(); }
private void Drumble() { if (!this.LocationSearchBoxModel.IsValid()) { base.ShowPopup(CustomPopupMessageType.Error, AppResources.WhereToLocationErrorPopupText, AppResources.CustomPopupGenericOkMessage, null); } else if (!this.DestinationSearchBoxModel.IsValid()) { base.ShowPopup(CustomPopupMessageType.Error, AppResources.WhereToDestinationErrorPopupText, AppResources.CustomPopupGenericOkMessage, null); } else if (departureTimeCustom != null && departureTimeCustom < DateTime.Now.AddMinutes(-5)) { base.ShowPopup(CustomPopupMessageType.Error, AppResources.WhereToCustomDateErrorPopupText, AppResources.CustomPopupGenericOkMessage, null); } else { IEnumerable <TransportMode> modes = UnitOfWork.TransportModeRepository.GetAll(); if (!modes.Any(x => x.IsEnabled)) { base.ShowPopup(CustomPopupMessageType.Error, AppResources.WhereToNoModesErrorPopupText, AppResources.CustomPopupGenericOkMessage, null); return; } IEnumerable <OperatorSetting> operatorSettings = UnitOfWork.OperatorSettingRepository.GetAll(); if (!operatorSettings.Any(x => x.IsEnabled)) { base.ShowPopup(CustomPopupMessageType.Error, AppResources.WhereToNoModesErrorPopupText, AppResources.CustomPopupGenericOkMessage, null); return; } DrumbleButtonIsEnabled = false; DrumbleCancelButtonVisibility = Visibility.Visible; ShowHeaderLoader(); Action getPath = async() => { try { DateTime createdDate = DateTime.UtcNow; // Try save a recent trip if user allows it. if (base.InMemoryApplicationSettingModel.GetSetting(ApplicationSetting.StoreRecent).Value) { Recent recentTripLocation = new Recent(this.LocationSearchBoxModel.TripOptions.Location, this.LocationSearchBoxModel.TripOptions.Text, createdDate, createdDate); UnitOfWork.RecentTripRepository.Insert(recentTripLocation); Recent recentTripDestination = new Recent(this.DestinationSearchBoxModel.TripOptions.Location, this.DestinationSearchBoxModel.TripOptions.Text, createdDate, createdDate); UnitOfWork.RecentTripRepository.Insert(recentTripDestination); UnitOfWork.Save(); } int? timeOffSetInMinutes = null; DateTime?seletedDepartureDate = null; if (selectedPredefinedDepartureTime != null) { timeOffSetInMinutes = selectedPredefinedDepartureTime.DepartureTimeInMinutes; } else if (departureTimeCustom != null) { seletedDepartureDate = departureTimeCustom.Value.ToUniversalTime(); } else { timeOffSetInMinutes = 0; } List <string> excludedModes = modes.Where(x => x.IsEnabled == false).Select(x => x.ApplicationTransportMode.ToString()).ToList(); List <string> excludedOperators = operatorSettings.Where(x => x.IsEnabled == false).Select(x => x.OperatorName).ToList(); cancellationTokenSource = new CancellationTokenSource(); IEnumerable <PathOption> pathOptionResults = await BumbleApiService.Path(cancellationTokenSource.Token, UnitOfWork.UserRepository.GetUser(), this.LocationSearchBoxModel.TripOptions.Location, this.DestinationSearchBoxModel.TripOptions.Location, isDeparting, seletedDepartureDate, timeOffSetInMinutes, excludedModes, excludedOperators); List <PathOption> pathOptions = pathOptionResults.ToList(); // Attempt to add an uber option. if (modes.Where(x => x.IsEnabled).Select(x => x.ApplicationTransportMode).Contains(ApplicationTransportMode.Taxi) && base.InMemoryApplicationSettingModel.GetSetting(ApplicationSetting.UseUber).Value && !UnitOfWork.UberTripRepository.ExistsCached()) { double maxDurationInMinutes = (!pathOptions.Any()) ? 0 : (pathOptions.Where(x => !x.IsUber).SelectMany(x => x.Stages).Max(x => x.EndTime) - DateTime.Now).TotalMinutes; pathOptions.Add(new PathOption(pathOptions.Count(), uberService, LocationSearchBoxModel.TripOptions.Location, DestinationSearchBoxModel.TripOptions.Location, maxDurationInMinutes, (user.UberInfo == null) ? null : user.UberInfo.AccessToken)); } if (!pathOptions.Any()) { base.ShowPopup(CustomPopupMessageType.Information, AppResources.WhereToNoResultsFound, AppResources.CustomPopupGenericOkMessage, null); HideHeaderLoader(); DrumbleButtonIsEnabled = true; DrumbleCancelButtonVisibility = Visibility.Collapsed; return; } DateTime startDate = DateTime.Now; UnitOfWork.PathRepository.RemoveAll(); UnitOfWork.Save(); foreach (PathOption pathOption in pathOptions.Where(x => !x.IsUber)) { if (pathOption.EndTime != null) { UnitOfWork.PathRepository.Insert(new Path(pathOption.TripId, startDate, pathOption.EndTime.Value, LocationSearchBoxModel.TripOptions.Text, DestinationSearchBoxModel.TripOptions.Text, LocationSearchBoxModel.TripOptions.Location, DestinationSearchBoxModel.TripOptions.Location, false, pathOption.JsonSerializedObject, pathOption.Order)); } } UnitOfWork.Save(); PathResultsModel results = new PathResultsModel(this.LocationSearchBoxModel.TripOptions.Address, this.DestinationSearchBoxModel.TripOptions.Address, pathOptions, BumbleApiService, user); SimpleIoc.Default.Unregister <PathResultsModel>(); SimpleIoc.Default.Register <PathResultsModel>(() => { return(results); }); SimpleIoc.Default.Unregister <TripResultsModel>(); SimpleIoc.Default.Register <TripResultsModel>(() => { return(new TripResultsModel()); }); if (base.InMemoryApplicationSettingModel.GetSetting(ApplicationSetting.SkipTripSelection).Value) { this.NavigationService.NavigateTo("/Views/TripDetails.xaml"); } else { this.NavigationService.NavigateTo("/Views/TripSelection.xaml"); } } catch (Exception e) { if (e.Message != "Cancelled") { base.ShowPopup(CustomPopupMessageType.Error, e.Message, AppResources.CustomPopupGenericOkMessage, null); } } HideHeaderLoader(); DrumbleButtonIsEnabled = true; DrumbleCancelButtonVisibility = Visibility.Collapsed; }; DispatcherHelper.CheckBeginInvokeOnUI(getPath); } }
public void OnDeserialized(StreamingContext context) { Favorites.RemoveAll(x => x.Address == null); Recent.RemoveAll(x => x.Address == null); }
public void RemoveRecent(Server server) { Recent.RemoveAllLocked(x => x.Address.Equals(server.Address)); server.LastJoinedOn = null; SaveSettings(); }
public RecentTripMessage(Recent recentTrip, RecentTripMessageReason reason) { this.RecentTrip = recentTrip; this.Reason = reason; }
public void RefreshFiltering() { Items.Refresh(); Popular.Refresh(); Recent.Refresh(); }