Esempio n. 1
0
        //得到所有公司关注人数
        public Dictionary <Company, UserDetailList> GetUserDetails(Guid correlationId)
        {
            List <Company> wwCompanylist = Utility.GetCompanys("ww");
            List <Company> gtCompanylist = Utility.GetCompanys("gt");
            string         appId         = "DC71D0B3-4FD2-4B4C-8EB7-E4988B476D3D";
            string         appSecret     = "a7abe4ee-c790-4ec0-aaa3-79fb9129c58b";
            string         wechatid      = "GetAllowUser";
            Dictionary <Company, UserDetailList> list = new Dictionary <Company, UserDetailList>();

            #region ww
            foreach (var company in wwCompanylist)
            {
                //step1.get dgtoken
                string dgtoken = Utility.GetDgToken(appId, appSecret, company.Id, wechatid, correlationId);
                //step2. get userinfo
                string restapi    = $"v1.0/wechat/departments/1/userdetailinfo?FetchChild=true&Status=1";
                string requestUrl = $"{Utility.DragonGateDomain}/{restapi}";
                Dictionary <string, string> headers = new Dictionary <string, string> {
                    { "dgToken", dgtoken }
                };
                SNHttpWebResponse response = WebHelper.GetRequest(requestUrl, headers);
                UserDetailList    result   = JsonConvert.DeserializeObject <UserDetailList>(response.ResponseStream);

                list.Add(company, result);
            }
            #endregion ww
            //---------------------------------------------------------------------------------------
            #region gt
            appId     = "729578B4-31EC-46F5-A388-6341FE9F4E77";
            appSecret = "0d118ccf-6bd2-41ca-a573-7bf52b246588";
            foreach (var company in gtCompanylist)
            {
                if (company.Id == "wx3f239ee0f2c6e820")
                {
                    continue;
                }
                //step1.get dgtoken
                string dgtoken = Utility.GetDgToken(appId, appSecret, company.Id, wechatid, correlationId);
                //step2. get userinfo
                string restapi    = $"v1.0/wechat/departments/1/userdetailinfo?FetchChild=true&Status=1";
                string requestUrl = $"{Utility.DragonGateDomain}/{restapi}";
                Dictionary <string, string> headers = new Dictionary <string, string> {
                    { "dgToken", dgtoken }
                };
                SNHttpWebResponse response = WebHelper.GetRequest(requestUrl, headers);
                UserDetailList    result   = JsonConvert.DeserializeObject <UserDetailList>(response.ResponseStream);
                list.Add(company, result);
            }
            #endregion gt

            return(list);
        }
Esempio n. 2
0
        /// <summary>
        /// Method To Show All Record
        /// </summary>
        public void UsersRecordList(object obj)
        {
            try
            {
                Count = 0;
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, "Called {2} function ::{0} {1}.", DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));

                if (obj == null)
                {
                    CurrentPageIndex = 0;
                }
                if (CurrentPageIndex == 0)
                {
                    Application.Current.Properties["FindUserGridLastScrollOffset"] = 0;
                    Application.Current.Properties["FindUserGridCurrentPageIndex"] = 0;
                }

                FindUserProp objFindUserProp = new FindUserProp();
                objFindUserProp.CurrentPageIndex = CurrentPageIndex;
                objFindUserProp.PageSize         = CurrentPageIndex > 0 ? _GridPageSizeOnScroll : _GridPageSize;;
                objFindUserProp.DefaultPageSize  = _GridPageSize;
                objFindUserProp.FirstName        = FirstName;
                objFindUserProp.LastName         = LastName;
                objFindUserProp.UserCode         = UserCode;
                objFindUserProp.SelectedRole     = RoleName;

                if (SelectedStatus != null && !SelectedStatus.Equals("All"))
                {
                    objFindUserProp.selectedStatusRole = SelectedStatus;
                }

                var list = _serviceInstance.GetUserRecord(objFindUserProp).Select(d => new UserDetails
                {
                    UdUserCode      = d.UserCode,
                    UdUserFirstName = d.FirstName,
                    UdUserLastName  = d.LastName,
                    UdUserStatus    = d.UserStatus,
                    UdUserID        = d.UserID,
                    TotalPageCount  = d.TotalPageCount
                });

                if (CurrentPageIndex == 0)
                {
                    UserDetailList = null;
                    UserDetailList = new ObservableCollection <UserDetails>(list);
                }
                else
                {
                    if (UserDetailList != null && UserDetailList.Count > 0)
                    {
                        foreach (UserDetails ud in new ObservableCollection <UserDetails>(list))
                        {
                            UserDetailList.Add(ud);
                        }
                    }
                }
                Count = userDetailList.ToList().Where(x => x.TotalPageCount > 0).FirstOrDefault().TotalPageCount;
            }
            catch (Exception ex)
            {
                LogHelper.LogErrorToDb(ex);
                bool displayErrorOnUI = false;
                CommonSettings.logger.LogError(this.GetType(), ex);
                if (displayErrorOnUI)
                {
                    throw;
                }
            }
            finally
            {
                CommonSettings.logger.LogInfo(typeof(string), string.Format(CultureInfo.InvariantCulture, Resources.loggerMsgEnd, DateTime.Now.ToShortDateString(), DateTime.Now.ToShortTimeString(), MethodBase.GetCurrentMethod().Name));

                if (_searchTimer != null)
                {
                    _searchTimer.Dispose();
                }
            }
        }