Пример #1
0
        public VoteDetailViewModel(VoteViewType type, int voteId, int groupMemberCount)
        {
            _voteId = voteId;
            var errCode = 0;
            var errMsg  = string.Empty;
            var output  = AntSdkService.GetVoteInfo(voteId, AntSdkService.AntSdkCurrentUserInfo.userId, ref errCode, ref errMsg);
            AntSdkQuerySystemDateOuput serverResult = AntSdkService.AntSdkGetCurrentSysTime(ref errCode, ref errMsg);
            DateTime serverDateTime = DateTime.Now;

            if (serverResult != null)
            {
                serverDateTime = PublicTalkMothed.ConvertStringToDateTime(serverResult.systemCurrentTime);
            }
            if (output != null)
            {
                SetVoteData(output, type, groupMemberCount, serverDateTime);
            }
        }
Пример #2
0
        private void SetVoteData(AntSdkGetVoteInfoOutput output, VoteViewType type, int groupMemberCount, DateTime serverDateTime)
        {
            AntSdkContact_User contactUser = AntSdkService.AntSdkListContactsEntity.users.Find(c => c.userId == output.createdBy);

            if (contactUser != null)
            {
                if (!string.IsNullOrWhiteSpace(contactUser.picture) && publicMethod.IsUrlRegex(contactUser.picture))
                {
                    var userImage = GlobalVariable.ContactHeadImage.UserHeadImages.FirstOrDefault(
                        m => m.UserID == contactUser.userId);
                    this.InitiatorHeadPic = string.IsNullOrEmpty(userImage?.Url)
                        ? contactUser.picture
                        : userImage.Url;
                }
                else
                {
                    this.InitiatorHeadPic = GlobalVariable.DefaultImage.UserHeadDefaultImage;
                }
                this.InitiatorName = contactUser.userName;
            }
            InitiateDateTime    = DataConverter.FormatTimeByCreateTime(output.createdDate);
            VoteTitle           = output.title;
            VoteState           = DateTime.Compare(Convert.ToDateTime(output.expiryTime), serverDateTime) < 0;
            VoteType            = output.maxChoiceNumber > 1 ? "多选" : "单选" + (output.secret ? "(匿名)" : "");
            _isSingle           = output.maxChoiceNumber <= 1;
            IsDisplayDeleteVote = output.createdBy == AntSdkService.AntSdkCurrentUserInfo.userId;
            VoteEndDateTime     = Convert.ToDateTime(output.expiryTime).ToString("yyyy-MM-dd HH:mm");

            //TotalVotes = groupMemberCount;
            IsDisplayNoVotes = !output.secret;

            if (VoteState)
            {
                IsDisplayAtBtn   = !VoteState;
                IsDisplayNoVotes = !VoteState;
            }
            else
            {
                IsDisplayAtBtn = !output.secret;
            }
            if (groupMemberCount > 0)
            {
                var memberCount = groupMemberCount - output.voters;
                NoVotes = memberCount > 0 ? memberCount : 0;
            }

            if (NoVotes == 0)
            {
                IsDisplayAtBtn = false;
            }
            if (type == VoteViewType.VoteDetail)
            {
                if (output.options != null && output.options.Count > 0)
                {
                    foreach (var opition in output.options)
                    {
                        VoteOptionList.Add(new OptionContent
                        {
                            OptionId   = opition.id,
                            OptionName = opition.name
                        });
                    }
                }
            }
            else
            {
                if (output.options != null && output.options.Count > 0)
                {
                    foreach (var opition in output.options)
                    {
                        VoteOptionList.Add(new OptionContent
                        {
                            OptionId              = opition.id,
                            OptionName            = opition.name,
                            OptionVotes           = opition.total,
                            IsCurrentUserSelected = opition.voted
                        });
                    }
                    TotalVotes = VoteOptionList.Sum(m => m.OptionVotes);
                }
                else
                {
                    TotalVotes = output.voters;
                }
            }
        }
Пример #3
0
 public VoteDetailViewModel(AntSdkGetVoteInfoOutput output, VoteViewType type, int groupMemberCount, DateTime serverDateTime)
 {
     _voteId = output.id;
     SetVoteData(output, type, groupMemberCount, serverDateTime);
 }