コード例 #1
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                EmployeeService                = ScopedServices.GetRequiredService <IEmployeeService>();
                HardwareVaultService           = ScopedServices.GetRequiredService <IHardwareVaultService>();
                OrgStructureService            = ScopedServices.GetRequiredService <IOrgStructureService>();
                SharedAccountService           = ScopedServices.GetRequiredService <ISharedAccountService>();
                RemoteDeviceConnectionsService = ScopedServices.GetRequiredService <IRemoteDeviceConnectionsService>();

                Companies = await OrgStructureService.GetCompaniesAsync();

                Departments = new List <Department>();
                Positions   = await OrgStructureService.GetPositionsAsync();

                SharedAccounts = await SharedAccountService.GetAllSharedAccountsAsync();

                SharedAccountId = SharedAccounts.FirstOrDefault()?.Id;

                await LoadHardwareVaultsAsync();

                Employee = new Employee()
                {
                    Id = Guid.NewGuid().ToString()
                };
                EmployeeContext = new EditContext(Employee);
                PersonalAccount = new AccountAddModel {
                    EmployeeId = Employee.Id, LoginType = LoginType.Local
                };
                PersonalAccountContext = new EditContext(PersonalAccount);

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                SetLoadFailed(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CloseAsync();
            }
        }