Exemplo n.º 1
0
        public void getUserTest3()
        {
            UsersResult result = jpushClient.getReportUsers(TimeUnit.HOUR, "2016-05-10 06", 10);

            Assert.IsTrue(result.isResultOK());
            Assert.IsTrue(result.items.Count > 0);
        }
Exemplo n.º 2
0
        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);
        }
Exemplo n.º 3
0
        public void getUserTest2()
        {
            UsersResult result = jpushClient.getReportUsers(TimeUnit.DAY, "2016-05-10", 5);

            Assert.IsTrue(result.isResultOK());
            Assert.IsTrue(result.items.Count > 0);
        }
Exemplo n.º 4
0
        public UsersResult getUsers(TimeUnit timeUnit, String start, int duration)
        {
            String url = REPORT_HOST_NAME + REPORT_USER_PATH
                         + "?time_unit=" + timeUnit.ToString()
                         + "&start=" + start + "&duration=" + duration;
            String          auth     = Base64.getBase64Encode(this.appKey + ":" + this.masterSecret);
            ResponseWrapper response = this.sendGet(url, auth, null);

            return(UsersResult.fromResponse(response));
        }
Exemplo n.º 5
0
        private void Print()
        {
            try
            {
                ClearStatusMessage();
                var    loginUser        = new List <LoginUser>();
                string serverPath       = null;
                var    salereport       = new SectionMasterReport();
                var    loginResult      = new UsersResult();
                int    sectionListCount = SectionList.Count;

                var task = ServiceProxyFactory.LifeTime(async factory =>
                {
                    serverPath  = await GetServerPath();
                    var client  = factory.Create <LoginUserMasterClient>();
                    loginResult = await client.GetItemsAsync(SessionKey, CompanyId, new LoginUserSearch());

                    if (sectionListCount > 0 && loginResult.ProcessResult.Result)
                    {
                        loginUser = loginResult.Users;
                        for (var i = 0; i < sectionListCount; i++)
                        {
                            SectionList[i].UpdateDate = SectionList[i].UpdateAt.ToString("yyyy/MM/dd");
                            for (var j = 0; j < loginUser.Count; j++)
                            {
                                if (SectionList[i].UpdateBy == loginUser[j].Id)
                                {
                                    SectionList[i].LoginUserName = loginUser[j].Name;
                                }
                            }
                        }
                        salereport.SetBasicPageSetting(Login.CompanyCode, Login.CompanyName);
                        salereport.Name = "入金部門マスター" + DateTime.Today.ToString("yyyyMMdd");
                        salereport.SetData(SectionList);
                        salereport.Run(true);
                    }
                });
                ProgressDialog.Start(ParentForm, Task.Run(() => task), false, SessionKey);

                if (sectionListCount > 0 && loginResult.ProcessResult.Result)
                {
                    ShowDialogPreview(ParentForm, salereport, serverPath);
                }
                else
                {
                    ShowWarningDialog(MsgWngPrintDataNotExist);
                }
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
                ShowWarningDialog(MsgErrCreateReportError);
            }
        }
Exemplo n.º 6
0
    public static UsersResult fromResponse(ResponseWrapper responseWrapper)
    {
        UsersResult usersResult = new UsersResult();

        if (responseWrapper.isServerResponse())
        {
            usersResult = JsonConvert.DeserializeObject <UsersResult> (responseWrapper.responseContent);
        }
        usersResult.ResponseResult = responseWrapper;
        return(usersResult);
    }
Exemplo n.º 7
0
        public UsersResult GetUser(int loggedUserId, int userId)
        {
            using (var db = _paintStoreContext)
            {
                var userToGet = db.Users.First(b => b.Id == userId);

                var followed = loggedUserId != -1 && db.UserFollowers.Any(x =>
                                                                          x.FollowedUserId == userToGet.Id && x.FollowingUserId == loggedUserId);

                var usersResult = new UsersResult(userToGet)
                {
                    Followed = followed
                };
                return(usersResult);
            }
        }
Exemplo n.º 8
0
        private void txtLoginUserCode_Validated(object sender, EventArgs e)
        {
            try
            {
                ClearStatusMessage();

                if (string.IsNullOrWhiteSpace(txtLoginUserCode.Text))
                {
                    lblLoginUserNames.Clear();
                    return;
                }

                var success = true;
                var task    = ServiceProxyFactory.LifeTime(async factory =>
                {
                    var service        = factory.Create <LoginUserMasterClient>();
                    UsersResult result = await service.GetByCodeAsync(
                        SessionKey, CompanyId, new[] { txtLoginUserCode.Text });

                    if (result.ProcessResult.Result && result.Users.Any())
                    {
                        await SetSectionWithLoginUser(result.Users[0]);
                    }
                    else
                    {
                        ShowWarningDialog(MsgWngMasterNotExist, "ログインユーザー", txtLoginUserCode.Text);
                        success = false;
                    }
                });
                ProgressDialog.Start(ParentForm, task, false, SessionKey);

                if (!success)
                {
                    txtLoginUserCode.Clear();
                    lblLoginUserNames.Clear();
                    txtLoginUserCode.Focus();
                }
            }
            catch (Exception ex)
            {
                Debug.WriteLine(ex.StackTrace);
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
            }
        }
Exemplo n.º 9
0
        /// <summary> 最終更新者取得 </summary>
        /// <param name="code"> 最終更新者コード</param>
        /// <returns>最終更新者名</returns>
        private string GetLoginUserName(string code)
        {
            string      name   = string.Empty;
            UsersResult result = null;
            Task        task   = ServiceProxyFactory.LifeTime(async factory =>
            {
                var service = factory.Create <LoginUserMasterClient>();
                result      = await service.GetByCodeAsync(SessionKey, CompanyId, new string[] { code });
            });

            ProgressDialog.Start(ParentForm, task, false, SessionKey);
            var user = result?.Users?.FirstOrDefault(x => x != null);

            if (user != null)
            {
                name = user.Name;
                ClearStatusMessage();
                UpdateBy = user.Id;
            }
            return(name);
        }
Exemplo n.º 10
0
        public async Task <IEnumerable <LoginUser> > SearchByKey(params string[] keys)
        {
            List <LoginUser> list = null;
            await ServiceProxyFactory.LifeTime(async factory =>
            {
                var service        = factory.Create <LoginUserMasterClient>();
                UsersResult result = await service.GetItemsAsync(Application.Login.SessionKey,
                                                                 Application.Login.CompanyId, new LoginUserSearch()
                {
                    UseCommonSearch = true,
                    Name            = keys[0]
                });

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

            return(list);
        }
Exemplo n.º 11
0
        /// <summary>
        /// This method user register details
        /// </summary>
        /// <param name="user">The user</param>
        /// <param name="password">The password</param>
        /// <returns></returns>
        public async Task <UsersResult> RegisterUser(ApplicationUser user, string password)
        {
            UserValidation.ValidateUserDetails(user);
            List <Errors> errorsList     = new List <Errors>();
            var           identityResult = await this.userDataService.RegisterUser(user, password);

            if (identityResult.Errors != null)
            {
                foreach (var identity in identityResult.Errors)
                {
                    var error = new Errors();
                    error.Code        = identity.Code;
                    error.Description = identity.Description;
                    errorsList.Add(error);
                }
            }
            var useResult = new UsersResult {
                ErrorList = errorsList, Status = identityResult.Succeeded
            };

            return(useResult);
        }
Exemplo n.º 12
0
        public AssignedToReportModel(ServicesProxy servicesProxy, User defaultEmployee = null)
        {
            Header           = new AssignedToReportTableItem();
            PostReportParams = new AssignedToReportParams();
            usersResult      = servicesProxy.UserService.GetUsers();

            if (servicesProxy.RequestState != null && servicesProxy.RequestState.UserDetails != null)
            {
                SelectedEmployee = defaultEmployee ?? usersResult.GetUser(servicesProxy.RequestState.UserDetails.Id);
            }

            if (SelectedEmployee == null)
            {
                SelectedEmployee = new User();
            }

            ReportParams = new AssignedToReportParams
            {
                AssignedTo = SelectedEmployee
            };

            Result = servicesProxy.ReportService.AssignedToReport(ReportParams);
        }
Exemplo n.º 13
0
        public UsersResult GetUsers(bool byDivision = false, bool fill = false)
        {
            try
            {
                InitCusRelContext();
                if (usersCache == null)
                {
                    usersCache = byDivision
                        ? cusRelContext.AuthorizedUsers.Where(u => u.Division != "IN").OrderBy(u => u.Division).ThenBy(u => u.UserName).ToList().Select(u => u.FromEntities()).ToList()
                        : cusRelContext.AuthorizedUsers.Where(u => u.Division != "IN").OrderBy(u => u.UserName).ThenBy(u => u.Division).ToList().Select(u => u.FromEntities()).ToList();
                }

                if (fill && groupContactsCache == null)
                {
                    if (groupContactsCache == null)
                    {
                        groupContactsCache = cusRelContext.tblCustomerReferenceCodes.ToList().FromEntities();
                    }

                    foreach (var user in usersCache)
                    {
                        user.GroupContact = groupContactsCache.FirstOrDefault(gc => gc.Code == user.GroupContact.Code);
                    }
                }

                return(new UsersResult
                {
                    Users = usersCache
                });
            }
            catch (Exception e)
            {
                var result = new UsersResult();
                result.SetFail(e);
                return(result);
            }
        }
Exemplo n.º 14
0
        private void Import()
        {
            ClearStatusMessage();
            try
            {
                ImportSetting importSetting = null;
                var           task          = Util.GetMasterImportSettingAsync(Login, ImportFileType.SectionWithLoginUser);
                ProgressDialog.Start(ParentForm, task, false, SessionKey);
                importSetting = task.Result;
                var definition = new SectionWithLoginUserFileDefinition(new DataExpression(ApplicationControl));
                definition.SectionCodeField.GetModelsByCode = val =>
                {
                    Dictionary <string, Section> product = null;
                    ServiceProxyFactory.LifeTime(factory =>
                    {
                        var section           = factory.Create <SectionMasterClient>();
                        SectionsResult result = section.GetByCode(SessionKey, CompanyId, val);

                        if (result.ProcessResult.Result)
                        {
                            product = result.Sections
                                      .ToDictionary(c => c.Code);
                        }
                    });
                    return(product ?? new Dictionary <string, Section>());
                };

                definition.LoginUserCodeField.GetModelsByCode = val =>
                {
                    Dictionary <string, LoginUser> product = null;
                    ServiceProxyFactory.LifeTime(factory =>
                    {
                        var loginUser   = factory.Create <LoginUserMasterClient>();
                        UsersResult res = loginUser.GetByCode(SessionKey, CompanyId, val);

                        if (res.ProcessResult.Result)
                        {
                            product = res.Users
                                      .ToDictionary(c => c.Code);
                        }
                    });
                    return(product ?? new Dictionary <string, LoginUser>());
                };

                var importer = definition.CreateImporter(m => new { m.LoginUserId, m.SectionId });
                importer.UserId      = Login.UserId;
                importer.UserCode    = Login.UserCode;
                importer.CompanyId   = CompanyId;
                importer.CompanyCode = Login.CompanyCode;
                importer.LoadAsync   = async() => await SectionWithLoginUserData();

                importer.RegisterAsync = async unitOfWork => await RegisterForImportAsync(unitOfWork);

                var importResult = DoImport(importer, importSetting);
                if (!importResult)
                {
                    return;
                }
                ClearFromTo();
                BeforeParentSearch();
                txtLoginUserCode.Clear();
                lblLoginUserNames.Clear();
                grdLoginUserModify.DataSource = null;
                grdLoginUserOrigin.DataSource = null;
                txtLoginUserCode.Focus();
                Modified = false;
            }
            catch (Exception ex)
            {
                Debug.Fail(ex.ToString());
                NLogHandler.WriteErrorLog(this, ex, SessionKey);
                ShowWarningDialog(MsgErrImportErrorWithoutLog);
            }
        }