Exemplo n.º 1
0
        private void LoadData(AttendanceRecord attendanceRecord)
        {
            var errCode = 0;
            var errMsg  = string.Empty;

            todayAttendanceRecords = attendanceRecord;
            if (todayAttendanceRecords == null)
            {
                return;
            }
            checkInDataTime = todayAttendanceRecords.PuncherDateTime;
            AntSdkQuerySystemDateOuput serverResult = AntSdkService.AntSdkGetCurrentSysTime(ref errCode, ref errMsg);
            DateTime serverDateTime = DateTime.Now;

            if (serverResult != null)
            {
                serverDateTime = PublicTalkMothed.ConvertStringToDateTime(serverResult.systemCurrentTime);
            }
            var diffMinute = serverDateTime - checkInDataTime;

            if (checkInDataTime.ToShortDateString() != serverDateTime.ToShortDateString())
            {
                return;
            }
            if (diffMinute.Hours > 6)
            {
                return;
            }
            if (diffMinute.Days > 0 || diffMinute.TotalMinutes > 20 || !todayAttendanceRecords.IsbtnVerify)
            {
                return;
            }
            //设置定时器
            timer?.Stop();
            timer          = null;
            timer          = new DispatcherTimer();
            timer.Interval = new TimeSpan(0, 0, 0, 1);   //时间间隔为一秒
            timer.Tick    += new EventHandler(timer_Tick);
            var minuteChangeSecond = 0d;

            if (diffMinute.TotalMinutes < 0)
            {
                minuteChangeSecond = (20 - 0.01) * 60;
            }
            else
            {
                minuteChangeSecond = (20 - diffMinute.TotalMinutes) * 60;
            }

            //处理倒计时的类
            processCount = new ProcessCount((int)minuteChangeSecond);
            //Application.Current.Dispatcher.Invoke((Action)(() =>
            //{
            todayAttendanceRecords.ChcekInTimer = "(" + processCount.GetMinute() + "分" + processCount.GetSecond() + "秒" + ")";
            //}));
            CountDown += new CountDownHandler(processCount.ProcessCountDown);

            //开启定时器
            timer.Start();
        }
Exemplo n.º 2
0
        public CreateVoteViewModel(string groupId)
        {
            _groupId = groupId;
            var errCode = 0;
            var errMsg  = string.Empty;
            AntSdkQuerySystemDateOuput serverResult = AntSdkService.AntSdkGetCurrentSysTime(ref errCode, ref errMsg);
            DateTime serverDateTime = DateTime.Now;

            if (serverResult != null)
            {
                serverDateTime = PublicTalkMothed.ConvertStringToDateTime(serverResult.systemCurrentTime);
            }
            _displayDateEnd = serverDateTime.AddMonths(1);
            InitData();
        }
Exemplo n.º 3
0
 /// <summary>
 /// Timer触发的事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void timer_Tick(object sender, EventArgs e)
 {
     if (OnCountDown())
     {
         //HourArea.Text = processCount.GetHour();
         //MinuteArea.Text = processCount.GetMinute();
         //SecondArea.Text = processCount.GetSecond();
         ChcekInTimer = processCount.GetMinute() + "分" + processCount.GetSecond() + "秒";
         ThreadPool.QueueUserWorkItem(m =>
         {
             if (processCount.timerTotalSecond >= 20)
             {
                 var errCode = 0;
                 var errMsg  = string.Empty;
                 AntSdkQuerySystemDateOuput serverResult = AntSdkService.AntSdkGetCurrentSysTime(ref errCode, ref errMsg);
                 DateTime serverDateTime = DateTime.Now;
                 if (serverResult != null)
                 {
                     serverDateTime = PublicTalkMothed.ConvertStringToDateTime(serverResult.systemCurrentTime);
                 }
                 var diffMinute = serverDateTime - checkInDataTime;
                 if (checkInDataTime.ToShortDateString() != serverDateTime.ToShortDateString())
                 {
                     return;
                 }
                 if (diffMinute.Days > 0 || diffMinute.TotalMinutes > 20)
                 {
                     return;
                 }
                 var minuteChangeSecond = (20 - diffMinute.TotalMinutes) * 60;
                 processCount.ResetTotalSecond((int)minuteChangeSecond);
             }
         });
     }
     else
     {
         if (VerifyView != null)
         {
             VerifyView.Close();
             //MainWindowViewModel.CloseExitVerify();
         }
         VerifyResultShow(true, CheckInVerifyResultState.TimeError);
         timer.Stop();
     }
 }
Exemplo n.º 4
0
 /// <summary>
 /// Timer触发的事件
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void timer_Tick(object sender, EventArgs e)
 {
     if (OnCountDown())
     {
         //Application.Current.Dispatcher.Invoke((Action)(() =>
         //{
         if (todayAttendanceRecords != null)
         {
             todayAttendanceRecords.ChcekInTimer = "(" + processCount.GetMinute() + "分" + processCount.GetSecond() + "秒" + ")";
         }
         ThreadPool.QueueUserWorkItem(m =>
         {
             if (processCount.timerTotalSecond >= 20)
             {
                 var errCode = 0;
                 var errMsg  = string.Empty;
                 AntSdkQuerySystemDateOuput serverResult = AntSdkService.AntSdkGetCurrentSysTime(ref errCode, ref errMsg);
                 DateTime serverDateTime = DateTime.Now;
                 if (serverResult != null)
                 {
                     serverDateTime = PublicTalkMothed.ConvertStringToDateTime(serverResult.systemCurrentTime);
                 }
                 var diffMinute = serverDateTime - checkInDataTime;
                 if (checkInDataTime.ToShortDateString() != serverDateTime.ToShortDateString())
                 {
                     return;
                 }
                 if (diffMinute.Days > 0 || diffMinute.TotalMinutes > 20)
                 {
                     return;
                 }
                 var minuteChangeSecond = (20 - diffMinute.TotalMinutes) * 60;
                 processCount.ResetTotalSecond((int)minuteChangeSecond);
             }
         });
         //}));
     }
     else
     {
         todayAttendanceRecords.IsbtnVerify    = false;
         todayAttendanceRecords.VerifyDescribe = "验证过期";
         todayAttendanceRecords.VerifyState    = 1;
         timer.Stop();
     }
 }
Exemplo n.º 5
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);
            }
        }
Exemplo n.º 6
0
        /// <summary>
        /// 分页查询投票数据
        /// </summary>
        private void LoadVotesData()
        {
            DateTime serverDateTime = DateTime.Now;

            AsyncHandler.CallFuncWithUI(System.Windows.Application.Current.Dispatcher,
                                        () =>
            {
                var errCode = 0;
                var errMsg  = string.Empty;
                AntSdkQuerySystemDateOuput serverResult = AntSdkService.AntSdkGetCurrentSysTime(ref errCode, ref errMsg);
                if (serverResult != null)
                {
                    serverDateTime = PublicTalkMothed.ConvertStringToDateTime(serverResult.systemCurrentTime);
                }
                var voteList = AntSdkService.GetGroupVotes(_groupId, ref errCode, ref errMsg, _page, _size,
                                                           AntSdkService.AntSdkCurrentUserInfo.userId);
                return(voteList);
            },
                                        (ex, datas) =>
            {
                VoteInfoList.Clear();
                if (datas?.content != null && datas.content.Count > 0)
                {
                    foreach (var voteInfo in datas.content)
                    {
                        var tempInfoModel         = new VoteInfoModel();
                        tempInfoModel.IsHaveVoted = voteInfo.voted;
                        if (voteInfo.createdBy == AntSdkService.AntSdkCurrentUserInfo.userId)
                        {
                            tempInfoModel.IsbtnDeleteVisibility = true;
                        }
                        tempInfoModel.VoteId   = voteInfo.id;
                        tempInfoModel.VoteSate =
                            DateTime.Compare(Convert.ToDateTime(voteInfo.expiryTime), serverDateTime) < 0;
                        tempInfoModel.VoteTitle = voteInfo.title + (voteInfo.secret ? "(匿名)" : "");
                        tempInfoModel.UserID    = voteInfo.createdBy;
                        AntSdkContact_User user = AntSdkService.AntSdkListContactsEntity.users.Find(c => c.userId == voteInfo.createdBy);
                        if (user != null)
                        {
                            tempInfoModel.Explain = user.userNum + user.userName + "  编辑于  " +
                                                    DataConverter.FormatTimeByCreateTime(voteInfo.createdDate);
                            if (!string.IsNullOrWhiteSpace(user.picture) && publicMethod.IsUrlRegex(user.picture))
                            {
                                var userImage =
                                    GlobalVariable.ContactHeadImage.UserHeadImages.FirstOrDefault(
                                        m => m.UserID == user.userId);
                                tempInfoModel.UserHeadUrl = string.IsNullOrEmpty(userImage?.Url) ? user.picture : userImage.Url;
                            }
                            else
                            {
                                tempInfoModel.UserHeadUrl = GlobalVariable.DefaultImage.UserHeadDefaultImage;
                            }
                        }
                        //tempInfoModel.UserHeadUrl=
                        _voteInfoList.Add(tempInfoModel);
                    }
                }
                if (datas != null)
                {
                    _isFirst = datas.first;
                    _isLast  = datas.last;
                }
            });
        }
Exemplo n.º 7
0
        public VoteListViewModel(string groupId)
        {
            _groupId      = groupId;
            _voteInfoList = new ObservableCollection <VoteInfoModel>();
            var errCode = 0;
            var errMsg  = string.Empty;
            AntSdkQuerySystemDateOuput serverResult = AntSdkService.AntSdkGetCurrentSysTime(ref errCode, ref errMsg);
            DateTime serverDateTime = DateTime.Now;

            if (serverResult != null)
            {
                serverDateTime = PublicTalkMothed.ConvertStringToDateTime(serverResult.systemCurrentTime);
            }
            var voteList = AntSdkService.GetGroupVotes(groupId, ref errCode, ref errMsg, _page, _size, AntSdkService.AntSdkCurrentUserInfo.userId);

            if (voteList?.content != null && voteList.content.Count > 0)
            {
                foreach (var voteInfo in voteList.content)
                {
                    var tempInfoModel = new VoteInfoModel();
                    tempInfoModel.IsHaveVoted = voteInfo.voted;
                    if (voteInfo.createdBy == AntSdkService.AntSdkCurrentUserInfo.userId)
                    {
                        tempInfoModel.IsbtnDeleteVisibility = true;
                    }
                    tempInfoModel.VoteId    = voteInfo.id;
                    tempInfoModel.VoteSate  = DateTime.Compare(Convert.ToDateTime(voteInfo.expiryTime), serverDateTime) < 0;
                    tempInfoModel.VoteTitle = voteInfo.title + (voteInfo.secret ? "(匿名)" : "");
                    tempInfoModel.UserID    = voteInfo.createdBy;
                    AntSdkContact_User user = AntSdkService.AntSdkListContactsEntity.users.Find(c => c.userId == voteInfo.createdBy);
                    if (user != null)
                    {
                        tempInfoModel.Explain = user.userNum + user.userName + "  编辑于  " +
                                                DataConverter.FormatTimeByCreateTime(voteInfo.createdDate);
                        if (!string.IsNullOrWhiteSpace(user.picture) && publicMethod.IsUrlRegex(user.picture))
                        {
                            var    index         = user.picture.LastIndexOf("/", StringComparison.Ordinal) + 1;
                            var    fileNameIndex = user.picture.LastIndexOf(".", StringComparison.Ordinal);
                            var    fileName      = user.picture.Substring(index, fileNameIndex - index);
                            string strUrl        = user.picture.Replace(fileName, fileName + "_35x35");
                            var    userImage     =
                                GlobalVariable.ContactHeadImage.UserHeadImages.FirstOrDefault(
                                    m => m.UserID == user.userId);
                            tempInfoModel.UserHeadUrl = string.IsNullOrEmpty(userImage?.Url) ? strUrl : userImage.Url;
                        }
                        else
                        {
                            tempInfoModel.UserHeadUrl = GlobalVariable.DefaultImage.UserHeadDefaultImage;
                        }
                    }
                    //tempInfoModel.UserHeadUrl=
                    _voteInfoList.Add(tempInfoModel);
                }
                _isFirst = voteList.first;
                _isLast  = voteList.last;
                IsPaging = !_isLast;
            }
            else
            {
                IsVoteData = true;
                IsPaging   = false;
            }
        }
Exemplo n.º 8
0
        public ActivityDetailsViewModel(int activityId, string groupId)
        {
            _activityId = activityId;
            _groupId    = groupId;
            var      errCode        = 0;
            var      errMsg         = string.Empty;
            DateTime serverDateTime = DateTime.Now;

            AsyncHandler.CallFuncWithUI(System.Windows.Application.Current.Dispatcher,
                                        () =>
            {
                AntSdkGetGroupActivityDetailsInput input = new AntSdkGetGroupActivityDetailsInput
                {
                    userId     = AntSdkService.AntSdkCurrentUserInfo.userId,
                    activityId = activityId,
                    groupId    = groupId
                };
                AntSdkQuerySystemDateOuput serverResult = AntSdkService.AntSdkGetCurrentSysTime(ref errCode,
                                                                                                ref errMsg);

                if (serverResult != null)
                {
                    serverDateTime = PublicTalkMothed.ConvertStringToDateTime(serverResult.systemCurrentTime);
                }
                var output = AntSdkService.GetActivityInfo(input, ref errCode, ref errMsg);
                return(output);
            },
                                        (ex, datas) =>
            {
                if (datas != null)
                {
                    ActivityTitle = datas.theme;
                    if (!string.IsNullOrEmpty(datas.picture))
                    {
                        try
                        {
                            BitmapImage image = new BitmapImage();

                            image.BeginInit();

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

                            image.DecodePixelWidth = 800;

                            image.EndInit();

                            ActivityThemePic = image;
                        }
                        catch (Exception e)
                        {
                            LogHelper.WriteError("[ActivityDetailsViewModel_ImageOnLoad]:" + e.Message + e.StackTrace + e.Source);
                        }
                    }
                    ActivityAddress   = datas.address;
                    ActivityIntroduce = datas.description;
                    latitude          = datas.latitude;
                    longitude         = datas.longitude;
                    Console.Out.WriteLine("");
                    var startTime = DateTime.Now;
                    var endTime   = DateTime.Now.AddMinutes(30);
                    if (!string.IsNullOrEmpty(datas.startTime) && !string.IsNullOrEmpty(datas.endTime))
                    {
                        startTime         = Convert.ToDateTime(datas.startTime);
                        endTime           = Convert.ToDateTime(datas.endTime);
                        TimeSpan timeSpan = endTime - startTime;
                        if (endTime.Year - startTime.Year == 0 && endTime.Day - startTime.Day == 0)
                        {
                            ActivityDateTime = startTime.ToString("yyyy-MM-dd HH:mm") + "-" +
                                               endTime.ToString("HH:mm");
                        }
                        else
                        {
                            ActivityDateTime = startTime.ToString("yyyy-MM-dd HH:mm") + "   " +
                                               endTime.ToString("yyyy-MM-dd HH:mm");
                        }
                    }
                    else
                    {
                        ActivityDateTime = startTime.ToString("yyyy-MM-dd HH:mm") + "-" +
                                           endTime.ToString("HH:mm");
                    }
                    ParticipatorsCount = datas.voteCount ?? 0;
                    if (datas.activityStatus == 1)
                    {
                        if (!datas.voteFlag)
                        {
                            if (DateTime.Compare(startTime, serverDateTime) <= 0)
                            {
                                ActivityStateContent   = "已开始";
                                IsParticipatedActivity = false;
                            }
                            else
                            {
                                ActivityStateContent   = "报名参加";
                                IsParticipatedActivity = true;
                            }
                        }
                        else
                        {
                            ActivityStateContent   = "已报名";
                            IsParticipatedActivity = false;
                        }
                    }
                    else
                    {
                        ActivityStateContent   = "已结束";
                        IsParticipatedActivity = false;
                    }
                    LoadActivityParticipators();
                }
            });
        }
Exemplo n.º 9
0
        //private bool CmdPing(string strIp)
        ////通过CMD中的ping命令去得电脑上网IP
        //{
        //    bool returnvalue = false;
        //    Process p = new Process(); p.StartInfo.FileName = "cmd.exe";//设定程序名
        //    p.StartInfo.UseShellExecute = false; //关闭Shell的使用
        //    p.StartInfo.RedirectStandardInput = true;//重定向标准输入
        //    p.StartInfo.RedirectStandardOutput = true;//重定向标准输出
        //    p.StartInfo.RedirectStandardError = true;//重定向错误输出
        //    p.StartInfo.CreateNoWindow = true;//设置不显示窗口
        //    p.Start(); p.StandardInput.WriteLine("ping -n 2 -w 1 -S " + strIp + " " + "GuangWang");
        //    p.StandardInput.WriteLine("exit");
        //    string strRst = p.StandardOutput.ReadToEnd();
        //    if (strRst.IndexOf("(100% 丢失)") != -1 || strRst.IndexOf("(100% loss)") != -1)
        //    {
        //        returnvalue = false;
        //    }
        //    else
        //    {
        //        returnvalue = true;
        //    }
        //    p.Close();
        //    return returnvalue;
        //}


        /// <summary>
        /// 加载初始化数据
        /// </summary>
        private void LoadData()
        {
            string _ComputName = System.Net.Dns.GetHostName();

            listIp = NetworkHelper.GetPhysicsNetworkCardIP();
            if (listIp.Count > 0)
            {
                hostIp = listIp[0];
            }
            //System.Net.IPAddress[] _IPList = System.Net.Dns.GetHostAddresses(_ComputName);
            //for (int i = 0; i != _IPList.Length; i++)
            //{
            //    if (_IPList[i].AddressFamily == System.Net.Sockets.AddressFamily.InterNetwork)
            //    {

            //            hostIp = _IPList[i].ToString();
            //            MessageBoxWindow.Show(hostIp, GlobalVariable.WarnOrSuccess.Success);
            //            break;

            //    }
            //}
            var errCode = 0;
            var errMsg  = string.Empty;
            AntSdkQuerySystemDateOuput serverResult = AntSdkService.AntSdkGetCurrentSysTime(ref errCode, ref errMsg);
            DateTime serverDateTime = DateTime.Now;

            if (serverResult != null)
            {
                serverDateTime = PublicTalkMothed.ConvertStringToDateTime(serverResult.systemCurrentTime);
            }
            var diffMinute = serverDateTime - checkInDataTime;

            if (checkInDataTime.ToShortDateString() != serverDateTime.ToShortDateString())
            {
                return;
            }
            if (diffMinute.Days > 0 || diffMinute.TotalMinutes > 20)
            {
                return;
            }
            //设置定时器
            timer          = new DispatcherTimer();
            timer.Interval = new TimeSpan(0, 0, 0, 1);    //时间间隔为一秒
            timer.Tick    += new EventHandler(timer_Tick);
            var minuteChangeSecond = 0d;

            if (diffMinute.TotalMinutes < 0)
            {
                minuteChangeSecond = (20 - 0.01) * 60;
            }
            else
            {
                minuteChangeSecond = (20 - diffMinute.TotalMinutes) * 60;
            }

            //处理倒计时的类
            processCount = new ProcessCount((int)minuteChangeSecond);
            ChcekInTimer = processCount.GetMinute() + "分" + processCount.GetSecond() + "秒";
            CountDown   += new CountDownHandler(processCount.ProcessCountDown);

            //开启定时器
            timer.Start();
        }