示例#1
0
        /// <summary>
        /// 分页查询投票数据
        /// </summary>
        private void LoadVotesData()
        {
            AsyncHandler.CallFuncWithUI(System.Windows.Application.Current.Dispatcher,
                                        () =>
            {
                var errCode = 0;
                var errMsg  = string.Empty;
                AntSdkGetGroupActivitysInput intput = new AntSdkGetGroupActivitysInput
                {
                    groupId        = _groupId,
                    activityStatus = 0,
                    pageNum        = _page,
                    pageSize       = _size,
                    userId         = AntSdkService.AntSdkCurrentUserInfo.userId
                };
                var activityList = AntSdkService.GetGroupActivitys(intput, ref errCode, ref errMsg);
                return(activityList);
            },
                                        (ex, datas) =>
            {
                ActivityInfoList.Clear();
                if (datas?.list != null && datas.list.Count > 0)
                {
                    foreach (var activityInfo in datas.list)
                    {
                        var tempInfoModel            = new ActivityInfoModel();
                        tempInfoModel.IsHaveActivity = activityInfo.voteFlag;
                        if (activityInfo.userId == AntSdkService.AntSdkCurrentUserInfo.userId)
                        {
                            tempInfoModel.IsbtnDeleteVisibility = true;
                        }
                        tempInfoModel.ActivityId = activityInfo.activityId;

                        tempInfoModel.ActivitySate  = activityInfo.activityStatus == 2;
                        tempInfoModel.ActivityTitle = activityInfo.theme;

                        AntSdkContact_User user = AntSdkService.AntSdkListContactsEntity.users.Find(c => c.userId == activityInfo.userId);
                        if (user != null)
                        {
                            if (!string.IsNullOrEmpty(activityInfo.picture))
                            {
                                BitmapImage image = new BitmapImage();

                                image.BeginInit();

                                image.UriSource = new System.Uri(activityInfo.picture);

                                image.DecodePixelWidth = 800;

                                image.EndInit();

                                image.Freeze();
                                tempInfoModel.ActivityThemePicture = image;
                            }
                            tempInfoModel.ActivityAddress     = activityInfo.address;
                            tempInfoModel.CreatedActivityDate = activityInfo.createTime;
                            if (!string.IsNullOrEmpty(activityInfo.startTime))
                            {
                                tempInfoModel.ActivityDate = Convert.ToDateTime(activityInfo.startTime).ToString("yyyy-MM-dd HH:mm");
                            }
                        }
                        //tempInfoModel.UserHeadUrl=
                        _activityInfoList.Add(tempInfoModel);
                    }
                }
                if (datas != null)
                {
                    _isFirst = datas.isFirstPage;
                    _isLast  = datas.isLastPage;
                }
            });
        }
示例#2
0
        public ActivityListViewModel(bool isAdminId, string groupId)
        {
            _isAdminId = isAdminId;
            if (!_isAdminId)
            {
                IsShowBtnAddActivity = false;
            }
            _groupId          = groupId;
            _activityInfoList = new ObservableCollection <ActivityInfoModel>();
            var errCode = 0;
            var errMsg  = string.Empty;

            AsyncHandler.CallFuncWithUI(System.Windows.Application.Current.Dispatcher,
                                        () =>
            {
                AntSdkGetGroupActivitysInput intput = new AntSdkGetGroupActivitysInput
                {
                    groupId        = _groupId,
                    activityStatus = 0,
                    pageNum        = _page,
                    pageSize       = _size,
                    userId         = AntSdkService.AntSdkCurrentUserInfo.userId
                };
                var activityList = AntSdkService.GetGroupActivitys(intput, ref errCode, ref errMsg);
                return(activityList);
            },
                                        (ex, datas) =>
            {
                if (datas?.list != null && datas.list.Count > 0)
                {
                    foreach (var activityInfo in datas.list)
                    {
                        var tempInfoModel            = new ActivityInfoModel();
                        tempInfoModel.IsHaveActivity = activityInfo.voteFlag;
                        if (activityInfo.userId == AntSdkService.AntSdkCurrentUserInfo.userId)
                        {
                            tempInfoModel.IsbtnDeleteVisibility = true;
                        }
                        tempInfoModel.ActivityId = activityInfo.activityId;

                        tempInfoModel.ActivitySate  = activityInfo.activityStatus == 2;
                        tempInfoModel.ActivityTitle = activityInfo.theme;

                        //AntSdkContact_User user = AntSdkService.AntSdkListContactsEntity.users.Find(c => c.userId == activityInfo.userId);
                        if (!string.IsNullOrEmpty(activityInfo.picture))
                        {
                            var index         = activityInfo.picture.LastIndexOf("/", StringComparison.Ordinal) + 1;
                            var fileNameIndex = activityInfo.picture.LastIndexOf(".", StringComparison.Ordinal);
                            var fileName      = activityInfo.picture.Substring(index, fileNameIndex - index);
                            string strUrl     = activityInfo.picture.Replace(fileName, fileName + "_80x80");
                            try
                            {
                                BitmapImage image = new BitmapImage();

                                image.BeginInit();

                                image.UriSource = new System.Uri(strUrl);

                                image.DecodePixelWidth = 800;

                                image.EndInit();

                                //image.Freeze();
                                tempInfoModel.ActivityThemePicture = image;
                            }
                            catch (Exception e)
                            {
                                LogHelper.WriteError("[ActivityListViewModel_ImageOnLoad]:" + e.Message + e.StackTrace + e.Source);
                            }
                        }

                        tempInfoModel.ActivityAddress     = activityInfo.address;
                        tempInfoModel.CreatedActivityDate = activityInfo.createTime;
                        if (!string.IsNullOrEmpty(activityInfo.startTime))
                        {
                            tempInfoModel.ActivityDate =
                                Convert.ToDateTime(activityInfo.startTime).ToString("yyyy-MM-dd HH:mm");
                        }
                        _activityInfoList.Add(tempInfoModel);
                    }
                    _isFirst = datas.isFirstPage;
                    _isLast  = datas.isLastPage;
                    IsPaging = !_isLast;
                }
                else
                {
                    IsActivityData = true;
                    IsPaging       = false;
                }
            });
        }