コード例 #1
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                Department = await OrgStructureService.GetDepartmentByIdAsync(DepartmentId);

                if (Department == null)
                {
                    throw new Exception("Department not found.");
                }

                EntityBeingEdited = MemoryCache.TryGetValue(Department.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(Department.Id, Department);
                }

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

                await ModalDialogService.CancelAsync();
            }
        }
コード例 #2
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                WorkstationService  = ScopedServices.GetRequiredService <IWorkstationService>();
                OrgStructureService = ScopedServices.GetRequiredService <IOrgStructureService>();
                RemoteWorkstationConnectionsService = ScopedServices.GetRequiredService <IRemoteWorkstationConnectionsService>();

                Workstation = await WorkstationService.GetWorkstationByIdAsync(WorkstationId);

                if (Workstation == null)
                {
                    throw new Exception("Workstation not found.");
                }

                EntityBeingEdited = MemoryCache.TryGetValue(Workstation.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(Workstation.Id, Workstation);
                }

                Companies = await OrgStructureService.GetCompaniesAsync();

                Departments = new List <Department>();

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
                await ModalDialogCancel();
            }
        }
コード例 #3
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                Company = await OrgStructureService.GetCompanyByIdAsync(CompanyId);

                if (Company == null)
                {
                    throw new Exception("Company not found.");
                }

                EntityBeingEdited = MemoryCache.TryGetValue(Company.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(Company.Id, Company);
                }

                SetInitialized();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
                await ModalDialogCancel();
            }
        }
コード例 #4
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                ModalDialogService.OnCancel += ModalDialogService_OnCancel;

                Position = await OrgStructureService.GetPositionByIdAsync(PositionId);

                if (Position == null)
                {
                    throw new Exception("Position not found.");
                }

                EntityBeingEdited = MemoryCache.TryGetValue(Position.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(Position.Id, Position);
                }

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

                await ModalDialogService.CancelAsync();
            }
        }
コード例 #5
0
        private async Task EditAsync()
        {
            try
            {
                await ButtonSpinner.SpinAsync(async() =>
                {
                    await OrgStructureService.EditDepartmentAsync(Department);
                    await ToastService.ShowToastAsync("Department updated.", ToastType.Success);
                    await Refresh.InvokeAsync(this);
                    await SynchronizationService.UpdateOrgSructureCompanies(ExceptPageId);
                    await ModalDialogService.CloseAsync();
                });
            }
            catch (AlreadyExistException ex)
            {
                ValidationErrorMessage.DisplayError(nameof(Department.Name), ex.Message);
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);

                await ModalDialogService.CloseAsync();
            }
        }
コード例 #6
0
ファイル: EditEmployee.razor.cs プロジェクト: minkione/HES
        public async Task OnCompanyChangeAsync(ChangeEventArgs args)
        {
            var companyId = (string)args.Value;

            if (companyId == string.Empty)
            {
                Employee.DepartmentId = null;
            }

            Departments = await OrgStructureService.GetDepartmentsByCompanyIdAsync(companyId);

            Employee.DepartmentId = Departments.FirstOrDefault()?.Id;
        }
コード例 #7
0
        public async Task DeleteAsync()
        {
            try
            {
                await OrgStructureService.DeleteDepartmentAsync(Department.Id);

                await ToastService.ShowToastAsync("Department removed.", ToastType.Success);
                await ModalDialogClose();
            }
            catch (Exception ex)
            {
                Logger.LogError(ex.Message, ex);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
                await ModalDialogCancel();
            }
        }
コード例 #8
0
        protected override async Task OnInitializedAsync()
        {
            try
            {
                EmployeeService     = ScopedServices.GetRequiredService <IEmployeeService>();
                OrgStructureService = ScopedServices.GetRequiredService <IOrgStructureService>();

                ModalDialogService.OnCancel += ModalDialogService_OnCancel;

                Employee = await EmployeeService.GetEmployeeByIdAsync(EmployeeId);

                if (Employee == null)
                {
                    throw new Exception("Employee not found.");
                }

                EntityBeingEdited = MemoryCache.TryGetValue(Employee.Id, out object _);
                if (!EntityBeingEdited)
                {
                    MemoryCache.Set(Employee.Id, Employee);
                }

                Companies = await OrgStructureService.GetCompaniesAsync();

                if (Employee.DepartmentId == null)
                {
                    Departments = new List <Department>();
                }
                else
                {
                    Departments = await OrgStructureService.GetDepartmentsByCompanyIdAsync(Employee.Department.CompanyId);
                }

                Positions = await OrgStructureService.GetPositionsAsync();

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

                await ModalDialogService.CancelAsync();
            }
        }
コード例 #9
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();
            }
        }
コード例 #10
0
 private async Task CreateAsync()
 {
     try
     {
         await Button.SpinAsync(async() =>
         {
             await OrgStructureService.CreatePositionAsync(Position);
             await ToastService.ShowToastAsync("Position created.", ToastType.Success);
             await ModalDialogClose();
         });
     }
     catch (AlreadyExistException ex)
     {
         ValidationErrorMessage.DisplayError(nameof(Position.Name), ex.Message);
     }
     catch (Exception ex)
     {
         Logger.LogError(ex.Message);
         await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
         await ModalDialogCancel();
     }
 }
コード例 #11
0
        public async Task DeleteAsync()
        {
            try
            {
                await OrgStructureService.DeleteDepartmentAsync(Department.Id);

                await Refresh.InvokeAsync(this);

                await SynchronizationService.UpdateOrgSructureCompanies(ExceptPageId);

                await ToastService.ShowToastAsync("Department removed.", ToastType.Success);

                await ModalDialogService.CloseAsync();
            }
            catch (Exception ex)
            {
                await ModalDialogService.CancelAsync();

                Logger.LogError(ex.Message, ex);
                await ToastService.ShowToastAsync(ex.Message, ToastType.Error);
            }
        }
コード例 #12
0
ファイル: PositionsTab.razor.cs プロジェクト: minkione/HES
        private async Task LoadPositionsAsync()
        {
            Positions = await OrgStructureService.GetPositionsAsync();

            StateHasChanged();
        }
コード例 #13
0
        protected override async Task ModalDialogCancel()
        {
            await OrgStructureService.UnchangedCompanyAsync(Company);

            await base.ModalDialogCancel();
        }
コード例 #14
0
 private async Task ModalDialogService_OnCancel()
 {
     await OrgStructureService.UnchangedDepartmentAsync(Department);
 }
コード例 #15
0
        private async Task ModalDialogService_OnCancel()
        {
            await OrgStructureService.UnchangedPositionAsync(Position);

            ModalDialogService.OnCancel -= ModalDialogService_OnCancel;
        }
コード例 #16
0
ファイル: EditPosition.razor.cs プロジェクト: minkione/HES
        protected override async Task ModalDialogCancel()
        {
            await OrgStructureService.UnchangedPositionAsync(Position);

            await base.ModalDialogCancel();
        }
コード例 #17
0
 private async Task ModalDialogService_OnCancel()
 {
     await OrgStructureService.UnchangedCompanyAsync(Company);
 }
コード例 #18
0
        protected override async Task ModalDialogCancel()
        {
            await OrgStructureService.UnchangedDepartmentAsync(Department);

            await base.ModalDialogCancel();
        }
コード例 #19
0
ファイル: CreateEmployee.razor.cs プロジェクト: minkione/HES
        private async Task CompanyChangedAsync(ChangeEventArgs args)
        {
            Departments = await OrgStructureService.GetDepartmentsByCompanyIdAsync(args.Value.ToString());

            Employee.DepartmentId = Departments.FirstOrDefault()?.Id;
        }
コード例 #20
0
        private async Task LoadCompaniesAsync()
        {
            Companies = await OrgStructureService.GetCompaniesAsync();

            StateHasChanged();
        }