Beispiel #1
0
        private void Button2_Click(object sender, EventArgs e)
        {
            Mode = CheckInMode.Single;
            var checkInUrl = this.GetCheckInLocation()?.url;

            CheckInSingleMember(checkInUrl);
        }
Beispiel #2
0
        /// <summary>
        /// 注册用户
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button4_Click(object sender, EventArgs e)
        {
            Mode = CheckInMode.Register;

            System.Diagnostics.Process          process   = new System.Diagnostics.Process();
            System.Diagnostics.ProcessStartInfo startInfo = new System.Diagnostics.ProcessStartInfo();
            startInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden;
            startInfo.FileName    = "checkin.exe";
            startInfo.Arguments   = $"{Constant.Host}/api/member/authorize?state=admin 1";

            process.StartInfo = startInfo;
            process.Start();
        }
Beispiel #3
0
        /// <summary>
        /// 批量打卡
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void Button1_Click(object sender, EventArgs e)
        {
            int lowerTimeSpanSeconds;
            int higherTimeSpanSeconds;

            try
            {
                lowerTimeSpanSeconds  = Convert.ToInt32(this.textBox1.Text);
                higherTimeSpanSeconds = Convert.ToInt32(this.textBox2.Text);
                if (lowerTimeSpan != 0 && higherTimeSpan != 0)
                {
                    this.lowerTimeSpan  = lowerTimeSpanSeconds * 1000;
                    this.higherTimeSpan = higherTimeSpanSeconds * 1000;
                }
            }
            catch (Exception)
            {
                Console.WriteLine("Format error");
            }

            this.lowerTimeSpan = Convert.ToInt32(this.textBox1.Text);
            var todaySeparator = DateTime.Today;

            todaySeparator = todaySeparator.AddHours(10);
            todaySeparator = todaySeparator.AddMinutes(30);

            var systemCheckInType = DateTime.Now >= todaySeparator ? CheckInType.CheckOut : CheckInType.CheckIn;

            if (getCheckInType() != systemCheckInType)
            {
                MessageBox.Show($"请选择正确的打卡类型, 当前时间: {DateTime.Now}");
                return;
            }

            var checkInUrl = GetCheckInLocation()?.url;

            Mode = CheckInMode.Batch;
            List <string> checkitems = new List <string>();

            MemberCheckInSingletonService.Instance.checkedInIds = new HashSet <string>();
            MemberCheckInSingletonService.Instance.needFaceIds  = new HashSet <string>();

            for (int i = 0; i < this.wait_checkin_datagrid.RowCount; i++)
            {
                if ((bool)this.wait_checkin_datagrid.Rows[i].Cells[0].Value)
                {
                    Member member = (Member)this.wait_checkin_datagrid.Rows[i].DataBoundItem;
                    checkitems.Add(member.ID);
                }
            }
            if (checkitems.Count > 0)
            {
                Task.Run(async() =>
                {
                    this.m_SyncContext.Post((context) =>
                    {
                        this.toolStripStatusLabel1.Text  = "正在更新需要打卡人员...";
                        this.toolStripProgressBar1.Value = 0;
                    }, this);

                    bool result = await MemberCheckInSingletonService.updateNeedCheckIn(checkitems);

                    this.m_SyncContext.Post((context) =>
                    {
                        this.toolStripProgressBar1.Value = 100;
                    }, this);

                    if (!result)
                    {
                        this.m_SyncContext.Post((context) =>
                        {
                            this.toolStripStatusLabel1.Text = "更新需要打卡人员失败";
                        }, this);

                        return;
                    }

                    MemberCheckInSingletonService.Instance.membercheckinlist.ForEach((item) =>
                    {
                        if (checkitems.FirstOrDefault(a => a == item._id) != null)
                        {
                            item.needChecked = NeeChecked.Need;
                        }
                        else
                        {
                            item.needChecked = NeeChecked.NoNeed;
                        }
                    });

                    this.m_SyncContext.Post((context) =>
                    {
                        List <MemberCheckIn> data = context as List <MemberCheckIn>;
                        var total = data.Count(item => item.status == CheckInStatus.Waiting);
                        this.toolStripProgressBar1.Step  = 100 / total;
                        this.toolStripProgressBar1.Value = 0;
                        this.toolStripStatusLabel1.Text  = $"[{total}条记录]准备中...";
                    }, MemberCheckInSingletonService.Instance.membercheckinlist);

                    CheckInSingleMember(checkInUrl);
                });
            }
            else
            {
                MemberCheckInSingletonService.Instance.membercheckinlist.ForEach((item) =>
                {
                    item.needChecked = NeeChecked.NoNeed;
                });
            }
        }