public object ModifyDtuRemoteConfigRequest([FromUri] int dtuId, [FromBody] DtuConfig dtuConfig) { // ET通信 ILog log = LogManager.GetLogger("DtuRemoteConfig"); log.DebugFormat("Instant DTU remote config: DTU={0}, dtuConfig={1}", dtuId, dtuConfig); // 设置消息头 Guid guid = Guid.NewGuid(); FsMessageHeader header = new FsMessageHeader { S = "WebClient", A = "GET", R = "/et/dtu/instant/at", // request url. U = guid, T = Guid.NewGuid() }; // 设置部分消息体 RemoteConfig rc = new RemoteConfig { Count = 2, Ip1 = dtuConfig.Ip, Port1 = dtuConfig.Port, Ip2 = dtuConfig.Ip2, Port2 = dtuConfig.Port2, Mode = dtuConfig.DtuMode.ToUpper(), ByteInterval = dtuConfig.PacketInterval, Retry = dtuConfig.ReconnectionCount }; List <CommandConfig> listCmd = RemoteConfigService.GetCommand(rc); FsMessage msg = new FsMessage { Header = header, Body = new { dtuId, cmds = listCmd } }; // return msg.Body; WebClientService.SendToET(msg); // 向ET Push DTU远程配置消息 using (var entity = new SecureCloud_Entities()) { var strGuid = guid.ToString(); var query = from ti in entity.T_TASK_INSTANT where ti.MSG_ID == strGuid select new { msgid = ti.MSG_ID }; var result = true; var list = query.ToList(); if (list.Count == 0) { result = false; } var json = new JObject( new JProperty("msgid", guid), new JProperty("result", result)); return(json); } }
public async void DoesNotShowTheRatingViewIfAfter24HourSnooze() { var defaultRemoteConfiguration = new RatingViewConfiguration(5, RatingViewCriterion.Start); RemoteConfigService .GetRatingViewConfiguration() .Returns(defaultRemoteConfiguration); var now = DateTimeOffset.Now; var firstOpened = now - TimeSpan.FromDays(6); var lastInteraction = now - TimeSpan.FromDays(2); TimeService.CurrentDateTime.Returns(now); OnboardingStorage.GetFirstOpened().Returns(firstOpened); OnboardingStorage.RatingViewOutcome().Returns(RatingViewOutcome.AppWasNotRated); OnboardingStorage.RatingViewOutcomeTime().Returns(lastInteraction); await ViewModel.Initialize(); var observer = TestScheduler.CreateObserver <bool>(); ViewModel.ShouldShowRatingView.Subscribe(observer); TestScheduler.Start(); observer.LastEmittedValue().Should().BeFalse(); }
public async void ShowsTheRatingView() { var defaultRemoteConfiguration = new RatingViewConfiguration(5, RatingViewCriterion.Start); RemoteConfigService .GetRatingViewConfiguration() .Returns(defaultRemoteConfiguration); var now = DateTimeOffset.Now; var firstOpened = now - TimeSpan.FromDays(5); TimeService.CurrentDateTime.Returns(now); OnboardingStorage.GetFirstOpened().Returns(firstOpened); await ViewModel.Initialize(); var observer = TestScheduler.CreateObserver <bool>(); ViewModel.ShouldShowRatingView.Subscribe(observer); TestScheduler.Start(); observer.LastEmittedValue().Should().BeTrue(); }
protected override void AdditionalSetup() { base.AdditionalSetup(); var syncManager = Substitute.For <ISyncManager>(); syncManager.ProgressObservable.Returns(ProgressSubject.AsObservable()); var defaultRemoteConfiguration = new RatingViewConfiguration(5, RatingViewCriterion.None); RemoteConfigService .GetRatingViewConfiguration() .Returns(defaultRemoteConfiguration); DataSource.Preferences.Current.Returns(Observable.Create <IThreadSafePreferences>(observer => { observer.OnNext(new MockPreferences { DateFormat = DateFormat.FromLocalizedDateFormat("dd/mm/YYYY") }); return(Disposable.Empty); })); }
public override async void ViewDidLoad() { Console.WriteLine("viewdidload"); Variables.ScreenHeight = View.Frame.Size.Height; Variables.ScreenWidth = View.Frame.Size.Width; await RemoteConfigService.GetCloudData("serviceconfig"); await RemoteConfigService.GetAppConfig("kconfig"); await MusicService.GetAndStoreRecentSongsAsync(); if (!string.IsNullOrEmpty(Variables.NowPlaying.ArtistId)) { NPArtist = await MusicService.GetArtistById(Convert.ToInt32(Variables.NowPlaying.ArtistId)); } SR = new SignalRService(); await SR.ConnectAsync(); SR.SongChanged += SignalR_SongChange; if (NPArtist != null) { NowPlayingArtistImageView = new UIImageView(View.Frame); NowPlayingArtistImageView.Image = await Functions.LoadImage(NPArtist.ImageUrl); NowPlayingArtistImageView.Frame = new CGRect(x: 0, y: 0, width: Variables.ScreenWidth, height: Variables.ScreenWidth / 2); // Add the Image View to the parent view View.AddSubview(NowPlayingArtistImageView); DarkGradientImageView = new UIImageView(View.Frame); DarkGradientImageView.Image = UIImage.FromBundle("dark-gradient.png"); DarkGradientImageView.Frame = new CGRect(x: 0, y: 0, width: Variables.ScreenWidth, height: Variables.ScreenHeight - ((Variables.ScreenHeight / 5) * 2)); View.AddSubview(DarkGradientImageView); RecentsImageView = new UIImageView(View.Frame); UIImage xI = await Functions.LoadImage(Variables.NowPlaying.AlbumImage); RecentsImageView.Image = xI; RecentsImageView.Frame = new CGRect(x: 0, y: Variables.ScreenHeight - ((Variables.ScreenHeight / 5) * 2), width: Variables.ScreenWidth, height: (Variables.ScreenHeight / 5) * 2); // Add the Image View to the parent view View.AddSubview(RecentsImageView); var blur = UIBlurEffect.FromStyle(UIBlurEffectStyle.Dark); float x = 0; float y = (float)(Variables.ScreenHeight - ((Variables.ScreenHeight / 5) * 2)); float width = (float)Variables.ScreenWidth; float height = (float)(Variables.ScreenHeight / 5 * 2); var blurView = new UIVisualEffectView(blur) { Frame = new RectangleF(x, y, width, height) }; View.Add(blurView); } TagLineImageView = new UIImageView(View.Frame); TagLineImageView.Image = UIImage.FromBundle("kl-logo-tagline-white.png"); TagLineImageView.ContentMode = UIViewContentMode.ScaleAspectFit; TagLineImageView.Frame = new CGRect(x: Variables.ScreenWidth * .042, y: Variables.ScreenHeight * .011, width: Variables.ScreenWidth * .13, height: Variables.ScreenWidth * .13); View.AddSubview(TagLineImageView); StartStopButton = new UIButton(UIButtonType.System); StartStopButton.SetTitle("Play", UIControlState.Normal); StartStopButton.TitleLabel.Font = UIFont.SystemFontOfSize(24, UIFontWeight.Bold); StartStopButton.TitleEdgeInsets = new UIEdgeInsets(0, -50, 0, -50); UIImage SSButtonIconImage = UIImage.FromBundle("play-fill.png"); StartStopButton.SetImage(SSButtonIconImage, UIControlState.Normal); StartStopButton.ImageView.ContentMode = UIViewContentMode.ScaleAspectFit; StartStopButton.ImageEdgeInsets = new UIEdgeInsets(-5, 0, -5, 50); StartStopButton.Frame = new CGRect(x: Variables.ScreenWidth * .042 + (Variables.ScreenHeight * .3) + (Variables.ScreenWidth * .02) + 32, y: Variables.ScreenHeight - ((Variables.ScreenHeight / 5) * 2) - 32, width: 220, height: 64); StartStopButton.PrimaryActionTriggered += async(sender, e) => { await AudioControl(); }; View.AddSubview(StartStopButton); LyricsButton = new UIButton(UIButtonType.System); LyricsButton.TitleLabel.Font = UIFont.SystemFontOfSize(24, UIFontWeight.Bold); LyricsButton.SetTitle("Lyrics", UIControlState.Normal); LyricsButton.TitleEdgeInsets = new UIEdgeInsets(0, -50, 0, -50); //LyricsButton.ImageEdgeInsets = new UIEdgeInsets(-5, 0, -5, 50); //UIImage LyButtonIconImage = UIImage.FromBundle("lyrics.png"); //LyricsButton.SetImage(LyButtonIconImage, UIControlState.Normal); //LyricsButton.ImageView.ContentMode = UIViewContentMode.ScaleAspectFit; LyricsButton.Frame = new CGRect(x: Variables.ScreenWidth * .042 + (Variables.ScreenHeight * .3) + (Variables.ScreenWidth * .02) + 284, y: Variables.ScreenHeight - ((Variables.ScreenHeight / 5) * 2) - 32, width: 220, height: 64); LyricsButton.PrimaryActionTriggered += async(sender, e) => { //await DisplayLyricsModal(); }; View.AddSubview(LyricsButton); ChannelsButton = new UIButton(UIButtonType.System); ChannelsButton.SetTitle("Channels", UIControlState.Normal); ChannelsButton.TitleLabel.Font = UIFont.SystemFontOfSize(24, UIFontWeight.Bold); ChannelsButton.TitleEdgeInsets = new UIEdgeInsets(0, -50, 0, -50); //UIImage ChButtonIconImage = UIImage.FromBundle("caret-down.png"); //ChannelsButton.ImageEdgeInsets = new UIEdgeInsets(-5, 0, -5, 50); //ChannelsButton.SetImage(ChButtonIconImage, UIControlState.Normal); //ChannelsButton.ImageView.ContentMode = UIViewContentMode.ScaleAspectFit; ChannelsButton.Frame = new CGRect(x: Variables.ScreenWidth * .042 + (Variables.ScreenHeight * .3) + (Variables.ScreenWidth * .02) + 536, y: Variables.ScreenHeight - ((Variables.ScreenHeight / 5) * 2) - 32, width: 220, height: 64); ChannelsButton.PrimaryActionTriggered += async(sender, e) => { await DisplayChannelModal(); }; View.AddSubview(ChannelsButton); NowPlayingImageView = new UIImageView(View.Frame); NowPlayingImageView.Image = await Functions.LoadImage(Variables.NowPlaying.AlbumImage); NowPlayingImageView.Frame = new CGRect(x: Variables.ScreenWidth * .042, y: (Variables.ScreenHeight * .55) - ((Variables.ScreenWidth / 4.5) / 2), width: Variables.ScreenHeight * .3, height: Variables.ScreenHeight * .3); // Add the Image View to the parent view View.AddSubview(NowPlayingImageView); ChannelTitleLabel = new UILabel(); ChannelTitleLabel.Text = Variables.CurrentChannel.Title.ToUpper(); ChannelTitleLabel.Font = UIFont.SystemFontOfSize(24); ChannelTitleLabel.TextColor = UIColor.White; ChannelTitleLabel.Alpha = .5f; ChannelTitleLabel.Frame = new CGRect(x: Variables.ScreenWidth * .042 + (Variables.ScreenHeight * .3) + (Variables.ScreenWidth * .02), y: (Variables.ScreenHeight * .55) - ((Variables.ScreenWidth / 4.5) / 2), width: Variables.ScreenWidth / 2, height: 46); View.AddSubview(ChannelTitleLabel); NowPlayingTitleLabel = new UILabel(); NowPlayingTitleLabel.Text = Variables.NowPlaying.SongTitle; NowPlayingTitleLabel.Font = UIFont.SystemFontOfSize(60, UIFontWeight.Bold); NowPlayingTitleLabel.TextColor = UIColor.White; NowPlayingTitleLabel.Frame = new CGRect(x: Variables.ScreenWidth * .042 + (Variables.ScreenHeight * .3) + (Variables.ScreenWidth * .02), y: ((Variables.ScreenHeight * .55) - ((Variables.ScreenWidth / 4.5) / 2)) + 31, width: (Variables.ScreenWidth / 3) * 2, height: 100); View.AddSubview(NowPlayingTitleLabel); NowPlayingArtistLabel = new UILabel(); NowPlayingArtistLabel.Text = Variables.NowPlaying.ArtistName; NowPlayingArtistLabel.Font = UIFont.SystemFontOfSize(48); NowPlayingArtistLabel.TextColor = UIColor.White; NowPlayingArtistLabel.Frame = new CGRect(x: Variables.ScreenWidth * .042 + (Variables.ScreenHeight * .3) + (Variables.ScreenWidth * .02), y: ((Variables.ScreenHeight * .55) - ((Variables.ScreenWidth / 4.5) / 2)) + 108, width: Variables.ScreenWidth / 2, height: 60); View.AddSubview(NowPlayingArtistLabel); LastPlayedLabel = new UILabel(); LastPlayedLabel.Text = "Last Played"; LastPlayedLabel.Font = UIFont.SystemFontOfSize(36, UIFontWeight.Bold); LastPlayedLabel.TextColor = UIColor.White; LastPlayedLabel.Frame = new CGRect(x: Variables.ScreenWidth * .042, y: (Variables.ScreenHeight * .7), width: Variables.ScreenWidth / 4, height: 54); View.AddSubview(LastPlayedLabel); await UpdateLastPlayedList(); FocusGuide = new UIFocusGuide(); View.AddLayoutGuide(FocusGuide); FocusGuide.LeftAnchor.ConstraintEqualTo(Recent4.LeftAnchor).Active = true; FocusGuide.TopAnchor.ConstraintEqualTo(ChannelsButton.TopAnchor).Active = true; FocusGuide.WidthAnchor.ConstraintEqualTo(Recent4.WidthAnchor).Active = true; FocusGuide.HeightAnchor.ConstraintEqualTo(ChannelsButton.HeightAnchor).Active = true; FocusGuide.PreferredFocusedView = StartStopButton; base.ViewDidLoad(); // Perform any additional setup after loading the view, typically from a nib. }
protected override void InitializeApp(IMvxPluginManager pluginManager, IMvxApplication app) { #if !USE_PRODUCTION_API System.Net.ServicePointManager.ServerCertificateValidationCallback += (sender, certificate, chain, sslPolicyErrors) => true; #endif const string clientName = "Daneel"; const string remoteConfigDefaultsFileName = "RemoteConfigDefaults"; var version = NSBundle.MainBundle.InfoDictionary["CFBundleShortVersionString"].ToString(); var database = new Database(); var scheduler = Scheduler.Default; var timeService = new TimeService(scheduler); var topViewControllerProvider = (ITopViewControllerProvider)Presenter; var mailService = new MailService(topViewControllerProvider); var dialogService = new DialogService(topViewControllerProvider); var platformConstants = new PlatformConstants(); var suggestionProviderContainer = new SuggestionProviderContainer( new MostUsedTimeEntrySuggestionProvider(database, timeService, maxNumberOfSuggestions) ); var intentDonationService = new IntentDonationService(); var privateSharedStorageService = new PrivateSharedStorageService(); var appVersion = Version.Parse(version); var keyValueStorage = new UserDefaultsStorage(); var permissionsService = new PermissionsService(); var userAgent = new UserAgent(clientName, version); var settingsStorage = new SettingsStorage(Version.Parse(version), keyValueStorage); var remoteConfigService = new RemoteConfigService(); remoteConfigService.SetupDefaults(remoteConfigDefaultsFileName); var schedulerProvider = new IOSSchedulerProvider(); var calendarService = new CalendarService(permissionsService); var notificationService = new NotificationService(permissionsService, timeService); var foundation = TogglFoundation .ForClient(userAgent, appVersion) .WithDatabase(database) .WithScheduler(scheduler) .WithMailService(mailService) .WithTimeService(timeService) .WithApiEnvironment(environment) .WithGoogleService <GoogleService>() .WithRatingService <RatingService>() .WithLicenseProvider <LicenseProvider>() .WithAnalyticsService(analyticsService) .WithSchedulerProvider(schedulerProvider) .WithPlatformConstants(platformConstants) .WithRemoteConfigService(remoteConfigService) .WithNotificationService(notificationService) .WithApiFactory(new ApiFactory(environment, userAgent)) .WithBackgroundService(new BackgroundService(timeService)) .WithApplicationShortcutCreator <ApplicationShortcutCreator>() .WithSuggestionProviderContainer(suggestionProviderContainer) .WithIntentDonationService(intentDonationService) .WithPrivateSharedStorageService(privateSharedStorageService) .WithPlatformInfo(platformInfo) .StartRegisteringPlatformServices() .WithDialogService(dialogService) .WithLastTimeUsageStorage(settingsStorage) .WithBrowserService <BrowserService>() .WithKeyValueStorage(keyValueStorage) .WithUserPreferences(settingsStorage) .WithCalendarService(calendarService) .WithOnboardingStorage(settingsStorage) .WithNavigationService(navigationService) .WithPermissionsService(permissionsService) .WithAccessRestrictionStorage(settingsStorage) .WithPasswordManagerService <OnePasswordService>() .WithErrorHandlingService(new ErrorHandlingService(navigationService, settingsStorage)) .WithFeedbackService(new FeedbackService(userAgent, mailService, dialogService, platformConstants)) .Build(); foundation.RevokeNewUserIfNeeded().Initialize(); base.InitializeApp(pluginManager, app); }