Exemplo n.º 1
0
        public void Setup()
        {
            _logger = (UnitTestLogger <CPU6502>)_serviceProvider.GetService <ILogger <CPU6502> >();
            _logger.GetOutput(); // Clear any buffered output

            mem = _serviceProvider.GetService <IAddressMap>();
            mem.Install(new Ram(0x0000, 0x10000));

            _display = _serviceProvider.GetService <IMemoryMappedDisplay>();
            _display.Locate(DISPLAY_BASE_ADDR, DISPLAY_SIZE);
            mem.Install(_display);
            AsyncUtil.RunSync(mem.Initialise);
            _display.Clear();
            _cpu          = (CPU6502)_serviceProvider.GetService <IDebuggableCpu>();
            _cpu.LogLevel = LogLevel.Trace;
            mem.WriteWord(_cpu.RESET_VECTOR, PROG_START);
            mem.Labels.Clear();
            mem.Labels.Add("DISPLAY_CONTROL_ADDR", MemoryMappedDisplay.DISPLAY_CONTROL_BLOCK_ADDR);
            mem.Labels.Add("DISPLAY_BASE_ADDR", DISPLAY_BASE_ADDR);
            mem.Labels.Add("DISPLAY_SIZE", DISPLAY_SIZE);
            mem.Labels.Add("RESET_VECTOR", _cpu.RESET_VECTOR);
            mem.Labels.Add("IRQ_VECTOR", _cpu.IRQ_VECTOR);
            mem.Labels.Add("NMI_VECTOR", _cpu.NMI_VECTOR);
            _cpuHoldEvent             = _serviceProvider.GetService <ICpuHoldEvent>();
            _cpuStepEvent             = _serviceProvider.GetService <ICpuStepEvent>();
            _cancellationTokenWrapper = _serviceProvider.GetService <CancellationTokenWrapper>();
            _cancellationTokenWrapper.Reset();
        }
Exemplo n.º 2
0
 /// <summary>
 /// カレンダーデータを取得する
 /// </summary>
 /// <returns></returns>
 private Dictionary <string, bool> GetCalendarData()
 {
     try
     {
         string          siteUrl    = UrlTextBox.Text.Trim();
         var             parameters = GetParameter();
         char            delimit    = CsvTypeRadio.Checked ? ',' : '\t';
         List <string[]> errMsg     = new List <string[]>();
         EncodeType      charset    = EncodeType.UTF8;
         if (EncodeSJISRadio.Checked)
         {
             charset = EncodeType.SHIFT_JIS;
         }
         if (EncodeEUCRadio.Checked)
         {
             charset = EncodeType.EUC_JP;
         }
         if (EncodeUTF16Radio.Checked)
         {
             charset = EncodeType.UTF16;
         }
         Dictionary <string, bool> result = AsyncUtil.RunSync(() => GetCalendarValueFromWeb(errMsg, siteUrl, parameters, delimit, charset));
         if (errMsg.Count > 0)
         {
             this.ShowWarningDialog(errMsg[0][0], errMsg[0][1]);
         }
         return(result);
     }
     catch (Exception ex)
     {
         throw Program.ThrowException(ex);
     }
 }
Exemplo n.º 3
0
        public List <MessageDto> GetList()
        {
            var _all     = AsyncUtil.RunSync(() => _dao.FindAllAsync());
            var _ordered = _all.ToList().OrderBy(o => o.DataLast).Take(10).ToList().MapToList <MessageDto>();

            return(_ordered);
        }
        private void Listen()
        {
            do
            {
                while (receiver.HasItems)
                {
                    var message = receiver.Peek();

                    // not sure how this ever happens but it does
                    if (message == null)
                    {
                        receiver.Dequeue();
                        continue;
                    }
                    var messageTypeName = message.ApplicationProperties[Constants.MESSAGE_TYPE_KEY] as string;
                    if (eventTypeLookup != null && !eventTypeLookup.ContainsKey(messageTypeName))
                    {
                        receiver.EnqueueUnmapped(message);
                        receiver.Dequeue();
                    }
                    else
                    {
                        AsyncUtil.RunSync(() => OnMessageCallbackAsync(message));
                    }
                }
                Thread.Sleep(500);
            } while (true);
        }
Exemplo n.º 5
0
        public void Start()
        {
            mem.Install(new Ram(0x0000, 0x10000));
            _display.Locate(DISPLAY_BASE_ADDR, DISPLAY_SIZE);
            mem.Install(_display);

            // This is interactive, so we want the RemoteKeyboardConnection
            mem.Install((IAddressAssignment)_keyboard);
            AsyncUtil.RunSync(() => mem.Initialise());
            _display.Clear();
            _cpu.LogLevel = LogLevel.Trace;

            _keyboard.RequestInterrupt += async(s, e) => { await _cpu.Interrupt(); };

            mem.WriteWord(_cpu.RESET_VECTOR, PROG_START);

            mem.Labels.Clear();
            mem.Labels.Add("DISPLAY_CONTROL_ADDR", MemoryMappedDisplay.DISPLAY_CONTROL_BLOCK_ADDR);
            mem.Labels.Add("DISPLAY_CONTROL_REGISTER", MemoryMappedDisplay.DISPLAY_CONTROL_BLOCK_ADDR + DisplayControlBlock.CONTROL_ADDR);
            mem.Labels.Add("CURSOR_X_REGISTER", MemoryMappedDisplay.DISPLAY_CONTROL_BLOCK_ADDR + DisplayControlBlock.CURSOR_X_ADDR);
            mem.Labels.Add("CURSOR_Y_REGISTER", MemoryMappedDisplay.DISPLAY_CONTROL_BLOCK_ADDR + DisplayControlBlock.CURSOR_X_ADDR);
            mem.Labels.Add("DISPLAY_BASE_ADDR", DISPLAY_BASE_ADDR);
            mem.Labels.Add("DISPLAY_SIZE", DISPLAY_SIZE);
            mem.Labels.Add("KEYBOARD_STATUS_REGISTER", MemoryMappedKeyboard.STATUS_REGISTER + KEYBOARD_BASE_ADDR);
            mem.Labels.Add("KEYBOARD_CONTROL_REGISTER", MemoryMappedKeyboard.CONTROL_REGISTER + KEYBOARD_BASE_ADDR);
            mem.Labels.Add("KEYBOARD_DATA_REGISTER", MemoryMappedKeyboard.DATA_REGISTER + KEYBOARD_BASE_ADDR);
            mem.Labels.Add("KEYBOARD_SCAN_CODE_REGISTER", MemoryMappedKeyboard.SCAN_CODE_REGISTER + KEYBOARD_BASE_ADDR);
            mem.Labels.Add("RESET_VECTOR", _cpu.RESET_VECTOR);
            mem.Labels.Add("IRQ_VECTOR", _cpu.IRQ_VECTOR);
            mem.Labels.Add("NMI_VECTOR", _cpu.NMI_VECTOR);

            Run();
        }
Exemplo n.º 6
0
 public void ContentService_Deleted(Umbraco.Core.Services.IContentService sender, Umbraco.Core.Events.DeleteEventArgs <Umbraco.Core.Models.IContent> e)
 {
     foreach (var item in e.DeletedEntities)
     {
         var properties = new PropertiesDictionary(item);
         AsyncUtil.RunSync(() => _messagingService.SendMessageAsync("contentService", "deleted", properties));
     }
 }
Exemplo n.º 7
0
 public void MediaService_Saved(Umbraco.Core.Services.IMediaService sender, Umbraco.Core.Events.SaveEventArgs <Umbraco.Core.Models.IMedia> e)
 {
     foreach (var item in e.SavedEntities)
     {
         var properties = new PropertiesDictionary(item);
         AsyncUtil.RunSync(() => _messagingService.SendMessageAsync("mediaService", "saved", properties));
     }
 }
Exemplo n.º 8
0
 protected MatchBase(IRepository <Company> companies, IRepository <Locality> localities,
                     IRepository <Classifier> classifiers)
 {
     Classifiers = classifiers;
     Localities  = localities;
     Companies   = companies;
     AsyncUtil.RunSync(Init);
 }
Exemplo n.º 9
0
        public void MediaService_Moved(Umbraco.Core.Services.IMediaService sender, Umbraco.Core.Events.MoveEventArgs <Umbraco.Core.Models.IMedia> e)
        {
            foreach (var item in e.MoveInfoCollection.Select(mi => mi.Entity))
            {
                var properties = new PropertiesDictionary(item);

                AsyncUtil.RunSync(() => _messagingService.SendMessageAsync("mediaService", "moved", properties));
            }
        }
Exemplo n.º 10
0
        public void UserService_DeletedUserGroup(Umbraco.Core.Services.IUserService sender, Umbraco.Core.Events.DeleteEventArgs <Umbraco.Core.Models.Membership.IUserGroup> e)
        {
            foreach (var item in e.DeletedEntities)
            {
                var properties = new PropertiesDictionary(item);

                AsyncUtil.RunSync(() => _messagingService.SendMessageAsync("userService", "deletedUserGroup", properties));
            }
        }
Exemplo n.º 11
0
        public App()
        {
            InitializeComponent();

            InitializeCustomComponents();

            InitializeApp();

            AsyncUtil.RunSync(() => InitializeNavigation());
        }
Exemplo n.º 12
0
        private void SubmitQuiz(string title = "Wynik")
        {
            GetUserAnswers();
            GetUserScore();

            string message = $"Uzyskano { _score} na {NumberOfQuestions} punktów";

            //tytuł jest w parametrach
            //uruchom metodę asynchroniczną synchronicznie
            AsyncUtil.RunSync(() => _dialogService.ShowMessage(message, title, null, () => Messenger.Default.Send("notification", Notifications.ChangeMainViewToWelcome)));
        }
Exemplo n.º 13
0
            public void OnDialogClosed(IQuickFilingDialog qfDialog)
            {
                if (!Electron.WindowManager.BrowserWindows.Any() || qfDialog.SelectedItem == null)
                {
                    return;
                }

                var hierarchyId = qfDialog.SelectedItem;
                var javascript  = $"{callbackFunction}('{hierarchyId}')";

                AsyncUtil.RunSync(() => ElectronUtils.ExecuteJavascript(javascript));
            }
Exemplo n.º 14
0
        static void Main(string[] args)
        {
            var serviceProvider = ConfigureServices();

            var dispatcher = serviceProvider.GetService <IDispatcher>();

            var result = AsyncUtil.RunSync(() => dispatcher.SendAsync <string>(new SampleCommandSequence()));

            Console.WriteLine($"Final result: {result}");

            Console.ReadLine();
        }
Exemplo n.º 15
0
        private void QuitQuiz()
        {
            string message = "Czy chcesz wyjść z quizu?";
            string title   = "Wyjście do menu głównego";

            //uruchom metodę asynchroniczną synchronicznie
            bool result = AsyncUtil.RunSync <bool>(() => _dialogService.ShowMessage(message, title, null, null, null));

            if (result)
            {
                Messenger.Default.Send("notification", Notifications.ChangeMainViewToWelcome);
            }
        }
Exemplo n.º 16
0
        public void ContentService_Published(Umbraco.Core.Services.IContentService sender, Umbraco.Core.Events.ContentPublishedEventArgs e)
        {
            foreach (var item in e.PublishedEntities)
            {
                var properties = new PropertiesDictionary(item);
                var publisher  = Current.Services.UserService.GetUserById(item.PublisherId.GetValueOrDefault());
                if (publisher != null)
                {
                    properties.Add("publisher", publisher.Name);
                }

                AsyncUtil.RunSync(() => _messagingService.SendMessageAsync("contentService", "published", properties, publisher));
            }
        }
Exemplo n.º 17
0
        public async Task <ApiResponse> Upsert(UserProfileDto userProfileDto)
        {
            try
            {
                var profileQuery = AsyncUtil.RunSync(() => _dao.FindAllAsync(f => f.User.Id.Equals(userProfileDto.Id)));
                var _daoUser     = new DbContextGenericDao <ApplicationUser>();
                var _user        = await _daoUser.LoadAsync(userProfileDto.Id);

                if (profileQuery.Any())
                {
                    UserProfile profile = profileQuery.First();
                    //_autoMapper.Map<UserProfileDto, UserProfile>(userProfileDto, profile);
                    profile.User            = _user;
                    profile.Count           = userProfileDto.Count;
                    profile.IsNavOpen       = userProfileDto.IsNavOpen;
                    profile.LastPageVisited = userProfileDto.LastPageVisited;
                    profile.IsNavMinified   = userProfileDto.IsNavMinified;
                    profile.LastUpdatedDate = DateTime.Now;
                    AsyncUtil.RunSync(() => _dao.SaveOrUpdateAsync(profile));
                    AsyncUtil.RunSync(() => _dao.FlushChangesAsync());
                }
                else
                {
                    //TODO review automapper settings
                    //_autoMapper.Map<UserProfileDto, UserProfile>(userProfileDto, profile);

                    UserProfile profile = new UserProfile
                    {
                        User            = _user,
                        Count           = userProfileDto.Count,
                        IsNavOpen       = userProfileDto.IsNavOpen,
                        LastPageVisited = userProfileDto.LastPageVisited,
                        IsNavMinified   = userProfileDto.IsNavMinified,
                        LastUpdatedDate = DateTime.Now
                    };
                    AsyncUtil.RunSync(() => _dao.SaveOrUpdateAsync(profile));
                    AsyncUtil.RunSync(() => _dao.FlushChangesAsync());
                }

                return(new ApiResponse(200, "Updated User Profile"));
            }
            catch (Exception ex)
            {
                string test = ex.Message;
                return(new ApiResponse(400, "Failed to Retrieve User Profile"));
            }
        }
Exemplo n.º 18
0
        public async Task <bool> Handle(SeedCommand request, CancellationToken cancellationToken)
        {
            Consoler.TitleStart("seed database start");

            var companies = CompanySpreadsheet.Import();

            //var chance = new ChanceNET.Chance();
            //var companies = new List<Company> {chance.Object<Company>()};

            var bus = IocContainer.Container.Resolve <ICommandBus>();

            /*
             *
             * DRGD - De-registered.
             * EXAD - External administration (in receivership/liquidation).
             * NOAC - Not active.
             * NRGD - Not registered.
             * PROV - Provisional (mentioned only under charges and refers
             * to those which have not been fully registered).
             * REGD – Registered.
             * SOFF - Strike-off action in progress.
             * DISS - Dissolved by Special Act of Parliament.
             * DIV3 - Organisation Transferred Registration via DIV3.
             * PEND - Pending - Schemes.
             *
             */
            foreach (var company in companies)//.Where(x=>x.Status =="REGD"))
            {
                var command = new CreateCompanyCommand(CompanyId.New)
                {
                    Company = company
                };
                try
                {
                    AsyncUtil.RunSync(() => bus.PublishAsync(command, cancellationToken));
                    await Task.CompletedTask;
                }
                catch (Exception e)
                {
                    Console.WriteLine(e);
                    throw;
                }
            }

            Consoler.TitleEnd("seed database finished");
            return(true);
        }
Exemplo n.º 19
0
        public string GetLastPageVisited(string userName)
        {
            var    userProfile     = AsyncUtil.RunSync(() => _dao.FindAllAsync(f => f.User.UserName.Equals(userName)));
            string lastPageVisited = "/dashboard";

            //var userProfile = from userProf in _db.UserProfiles
            //                  join user in _db.Users on userProf.UserId equals user.Id
            //                  where user.UserName == userName
            //                  select userProf;

            if (userProfile.Any())
            {
                lastPageVisited = !String.IsNullOrEmpty(userProfile.First().LastPageVisited) ? userProfile.First().LastPageVisited : lastPageVisited;
            }

            return(lastPageVisited);
        }
Exemplo n.º 20
0
        public void Write(ushort address, byte value)
        {
            lock (this)
            {
                switch (address)
                {
                case STATUS_REGISTER:
                    _current = null;
                    break;

                case CONTROL_REGISTER:
                    _controlRegister = (byte)(value & 0x7);
                    AsyncUtil.RunSync(SendControlRegister);
                    break;
                }
            }
        }
Exemplo n.º 21
0
        public void Setup()
        {
            _cpuDebug   = _serviceProvider.GetService <IDebuggableCpu>();
            _addressMap = _serviceProvider.GetService <IAddressMap>();
            AsyncUtil.RunSync(_addressMap.Initialise);

            _labels = _serviceProvider.GetService <ILabelMap>();
            _labels.Clear();
            _logFormatter = _serviceProvider.GetService <ILogFormatter>();
            _parser       = _serviceProvider.GetService <IParser>();
            _logger       = (UnitTestLogger <Parser>)_serviceProvider.GetService <ILogger <Parser> >();
            _cpuDebug.Breakpoints.Clear();
            _cpuHoldEvent = (MockCpuHoldEvent)_serviceProvider.GetService <ICpuHoldEvent>();
            _cpuStepEvent = (MockCpuStepEvent)_serviceProvider.GetService <ICpuStepEvent>();
            _cpuHoldEvent.Init();
            _cpuStepEvent.Init();
            _logger.GetOutput(); // Flush any old content
        }
Exemplo n.º 22
0
 public void Execute(bool localities = false, bool companies = false, bool keywords = false, bool charges = false)
 {
     if (localities)
     {
         ImportLocalities();
     }
     if (companies)
     {
         ImportCompanies();
     }
     if (keywords)
     {
         ImportKeywords();
     }
     if (charges)
     {
         AsyncUtil.RunSync(ImportCharges);
     }
 }
Exemplo n.º 23
0
        private void PreloadAssets()
        {
            Console.WriteLine("Scanning remote database for assets to preload");
            ScanOperationConfig assetsConfig = new ScanOperationConfig();
            Search assetsSearch = AssetsTable.Scan(assetsConfig);

            List <Document> assetList = new List <Document>();

            do
            {
                assetList = AsyncUtil.RunSync(() => assetsSearch.GetNextSetAsync());
                //assetList = await assetsSearch.GetNextSetAsync();
                foreach (var document in assetList)
                {
                    string asset = document["scripthash"];
                    Console.WriteLine($"Preloading asset {asset}");
                    Assets.Add(asset);
                }
            } while (!assetsSearch.IsDone);
        }
Exemplo n.º 24
0
 /// <summary>
 /// WEBデータを取得する
 /// </summary>
 /// <returns></returns>
 private List <List <string> > GetWebData()
 {
     try
     {
         string                siteUrl    = FileInoutPathTextBox.Text.Trim();
         var                   parameters = GetParameter();
         char                  delimit    = CsvSeparateRadio.Checked ? ',' : '\t';
         List <string[]>       errMsg     = new List <string[]>();
         List <List <string> > result     = AsyncUtil.RunSync(() => GetValueFromWeb(errMsg, siteUrl, parameters, delimit));
         if (errMsg.Count > 0)
         {
             this.ShowWarningDialog(errMsg[0][0], errMsg[0][1]);
         }
         return(result);
     }
     catch (Exception ex)
     {
         throw Program.ThrowException(ex);
     }
 }
        public bool FinishedLaunching(UIApplication application, NSDictionary launchOptions)
        {
            if (UIDevice.CurrentDevice.CheckSystemVersion(10, 0))
            {
                UNUserNotificationCenter.Current.RequestAuthorization(UNAuthorizationOptions.Alert |
                                                                      UNAuthorizationOptions.Badge | UNAuthorizationOptions.Sound,
                                                                      (granted, error) =>
                {
                    if (granted)
                    {
                        InvokeOnMainThread(UIApplication.SharedApplication.RegisterForRemoteNotifications);
                    }
                });
            }

            UNUserNotificationCenter.Current.Delegate = new UserNotificationCenterDelegate();

            AsyncUtil.RunSync(() => LogInProcessing());

            return(true);
        }
Exemplo n.º 26
0
        private void PreloadContracts()
        {
            Console.WriteLine("Scanning remote database for contracts to preload");
            ScanOperationConfig contractsconfig = new ScanOperationConfig();
            Search contractsSearch = ContractsTable.Scan(contractsconfig);

            List <Document> contractList = new List <Document>();
            int             idx          = 0;

            do
            {
                contractList = AsyncUtil.RunSync(() => contractsSearch.GetNextSetAsync());
                //contractList = await contractsSearch.GetNextSetAsync();
                foreach (var document in contractList)
                {
                    string contract = document["hash"];
                    Console.WriteLine($"Preloading contract {contract}");
                    Contracts.Add(contract);
                    idx++;
                }
            } while (!contractsSearch.IsDone);
        }
Exemplo n.º 27
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(
            IApplicationBuilder app,
            IWebHostEnvironment env,
            IHostApplicationLifetime applicationLifetime)
        {
            using (var serviceScope = app.ApplicationServices.GetService <IServiceScopeFactory>().CreateScope())
            {
                var context = serviceScope.ServiceProvider.GetRequiredService <AddressBookContext>();

                context.Database.EnsureCreated();
            }

            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
                app.UseSwagger();
                app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "AddressBook API v1"));
            }

            app.UseHttpsRedirection();

            app.UseCustomExceptionHandler();

            app.UseRouting();

            app.UseCors(nameof(AddressBook));

            app.UseAuthorization();

            app.UseEndpoints(endpoints =>
            {
                endpoints.MapControllers();
            });

            AsyncUtil.RunSync(() => app.ApplicationServices.GetRequiredService <IDataSeed>()
                              .SeedAllInitialDataAsync(applicationLifetime.ApplicationStopping));
        }
Exemplo n.º 28
0
        private string GetErrorDescription(HttpContent content, LogContext logContext, MethodType methodType)
        {
            // Error responses come if a couple of different formats...
            string responseBody = string.Empty;
            string errorMessage = string.Empty;

            try
            {
                // Get the message body for rethrow, with body included
                responseBody = AsyncUtil.RunSync(content.ReadAsStringAsync);

                try
                {
                    // Try error format #1
                    ErrorResponse errorResponse = JsonConvert.DeserializeObject <ErrorResponse>(responseBody);
                    errorMessage = errorResponse.ErrorDetail.Message;
                }
                catch (JsonSerializationException)
                {
                    // That didn't work, so try error format #2
                    ErrorResponseBasic errorResponseBasic = JsonConvert.DeserializeObject <ErrorResponseBasic>(responseBody);
                    errorMessage = errorResponseBasic.Description;
                }
            }
            catch (Exception)
            {
                // Unexpected condition, likely to be hit only if some new error response format is added to the API.
                logger?.LogWarning(
                    logContext.EventId,
                    "{CorrelationId} {HttpMethod} Failed to parse error response body:\n{ResponseBody}",
                    logContext.CorrelationId,
                    methodType.ToString().ToUpperInvariant(),
                    responseBody);
            }

            return(errorMessage);
        }
 /// <summary>
 /// Retrieve Locations Maps.
 /// </summary>
 /// <remarks>
 /// Retrieves a list of all locations maps associated with your company,
 /// with optional filters to narrow down the results.
 /// </remarks>
 /// <param name="filter">
 /// An instance of the <see cref="LocationsMapFilter"/> class, for narrowing down the results.
 /// </param>
 /// <returns>
 /// An enumerable set of <see cref="LocationsMap"/> objects, along with an output
 /// instance of the <see cref="ResultsMeta"/> class containing additional data.
 /// </returns>
 public (IList <LocationsMap>, ResultsMeta) GetLocationsMaps(
     LocationsMapFilter filter)
 {
     return(AsyncUtil.RunSync(() => GetLocationsMapsAsync(filter)));
 }
 /// <summary>
 /// Retrieve Locations Maps.
 /// </summary>
 /// <remarks>
 /// Retrieves a list of all locations maps associated with your company,
 /// with optional filters to narrow down the results.
 /// </remarks>
 /// <param name="options">
 /// An instance of the <see cref="RequestOptions"/> class, for customizing method processing.
 /// </param>
 /// <returns>
 /// An enumerable set of <see cref="LocationsMap"/> objects, along with an output
 /// instance of the <see cref="ResultsMeta"/> class containing additional data.
 /// </returns>
 public (IList <LocationsMap>, ResultsMeta) GetLocationsMaps(
     RequestOptions options)
 {
     return(AsyncUtil.RunSync(() => GetLocationsMapsAsync(options)));
 }