コード例 #1
0
ファイル: LoginUserGridLoader.cs プロジェクト: fwka1605/next
        public async Task <IEnumerable <LoginUser> > SearchInfo()
        {
            List <LoginUser> list = null;
            await ServiceProxyFactory.LifeTime(async factory =>
            {
                var service = factory.Create <LoginUserMasterClient>();
                LoginUserSearch loginUserSearch;
                if (onlyUseClient)
                {
                    loginUserSearch = new LoginUserSearch {
                        UseClient = 1
                    };
                }
                else
                {
                    loginUserSearch = new LoginUserSearch();
                }

                UsersResult result = await service.GetItemsAsync(Application.Login.SessionKey,
                                                                 Application.Login.CompanyId, loginUserSearch);

                if (result.ProcessResult.Result)
                {
                    list = result.Users;
                }
            });

            return(list);
        }
コード例 #2
0
        public Task <IEnumerable <LoginUser> > GetAsync(LoginUserSearch option, CancellationToken token = default(CancellationToken))
        {
            var query = @"
SELECT        lu.*
            , dt.Code as DepartmentCode
            , dt.Name AS DepartmentName
            , st.Code AS StaffCode
            , st.Name AS StaffName
FROM        LoginUser AS lu
LEFT JOIN   Department AS dt    ON dt.Id    = lu.DepartmentId
LEFT JOIN   Staff AS st         ON st.Id    = lu.AssignedStaffId
WHERE       lu.Id               = lu.Id";

            if (option.CompanyId.HasValue)
            {
                query += @"
AND         lu.CompanyId        = @CompanyId";
            }
            if (option.Ids?.Any() ?? false)
            {
                query += @"
AND         lu.Id               IN (SELECT Id   FROM @Ids)";
            }

            if (option.Codes?.Any() ?? false)
            {
                query += @"
AND         lu.Code             IN (SELECT Code FROM @Codes)";
            }
            if (!string.IsNullOrWhiteSpace(option.Name))
            {
                option.Name = Sql.GetWrappedValue(option.Name);
                query      += @"
AND         lu.Name             LIKE @Name";
            }
            if (option.UseClient.HasValue)
            {
                query += @"
AND         lu.UseClient        = @UseClient";
            }
            if (option.ExcludeCodes?.Any() ?? false)
            {
                query += @"
AND         EXISTS (
            SELECT      1
            FROM        SectionWithLoginUser swl
            WHERE       swl.LoginUserId     = lu.Id
            )
AND         lu.Code         NOT IN (SELECT Code FROM @ExcludeCodes)";
            }

            query += @"
ORDER BY      lu.CompanyId      ASC
            , lu.Code           ASC";

            return(dbHelper.GetItemsAsync <LoginUser>(query, new {
                option.CompanyId,
                option.Name,
                option.UseClient,
                Ids = option.Ids.GetTableParameter(),
                Codes = option.Codes.GetTableParameter(),
                ExcludeCodes = option.ExcludeCodes.GetTableParameter(),
            }, token));
        }
コード例 #3
0
 public async Task <IEnumerable <LoginUser> > GetAsync(LoginUserSearch option, CancellationToken token = default(CancellationToken))
 => await loginUserQueryProcessor.GetAsync(option, token);
コード例 #4
0
 public async Task <IEnumerable <LoginUser> > GetItems(LoginUserSearch option, CancellationToken token)
 => (await loginUserProcessor.GetAsync(option, token)).ToArray();
コード例 #5
0
ファイル: LoginUserMaster.svc.cs プロジェクト: fwka1605/next
 public async Task <UsersResult> GetItemsAsync(string SessionKey, int CompanyId, LoginUserSearch LoginUserSearch)
 {
     return(await authorizationProcessor.DoAuthorizeAsync(SessionKey, async token =>
     {
         LoginUserSearch.CompanyId = CompanyId;
         var result = (await loginUserProcessor.GetAsync(LoginUserSearch, token)).ToList();
         return new UsersResult
         {
             ProcessResult = new ProcessResult {
                 Result = true
             },
             Users = result,
         };
     }, logger));
 }