Пример #1
0
        void ClearAccount()
        {
            Name     = Properties.Settings.Default.Name = "";
            Password = Properties.Settings.Default.Password = "";

            Properties.Settings.Default.Save();

            Fufu.logout();
            Logs.Clear();
        }
Пример #2
0
        public override void Dispose()
        {
            base.Dispose();

            Config.saveConfig();

            foreach (var f in filters)
            {
                if (f is IDisposable)
                {
                    (f as IDisposable).Dispose();
                }
            }

            Fufu.logout();
        }
Пример #3
0
        public override void Dispose()
        {
            base.Dispose();
            Properties.Settings.Default.Name     = Name;
            Properties.Settings.Default.Password = Security.Encrypt(Password, "p@ssw0rd");

            Config.saveConfig();
            Properties.Settings.Default.Save();

            foreach (var f in filters)
            {
                if (f is IDisposable)
                {
                    (f as IDisposable).Dispose();
                }
            }

            Fufu.logout();
        }
Пример #4
0
        async Task <Log> getLogAsync(DateTime dt)
        {
            var log = await Fufu.getLogAsync(dt);

            if (log == null)
            {
                return(null);
            }
            // 预处理
            foreach (var f in filters)
            {
                f.PreFilter(log, Logs.Count > 0 ? Logs[Logs.Count - 1] : null);
            }
            // 后处理
            foreach (var f in filters)
            {
                f.Filter(log);
            }
            return(log);
        }
Пример #5
0
        async Task getLogAsync(DateTime date)
        {
            if (string.IsNullOrEmpty(Name) || string.IsNullOrEmpty(Password))
            {
                return;
            }

            if (inwork)
            {
                return;
            }

            try {
                inwork = true;
                if (!await Fufu.loginAsync(Name, Password))
                {
                    goto _end_;
                }

                TotalDay  = 0;
                FinishDay = 0;
                Logs.Clear();
                for (int i = date.Day; i > 0; i--)
                {
                    var d   = new DateTime(date.Year, date.Month, i);
                    var log = await Fufu.getLogAsync(d);

                    if (log == null)
                    {
                        continue;
                    }

                    // 预处理
                    foreach (var f in filters)
                    {
                        f.PreFilter(log, Logs.Count > 0 ? Logs[Logs.Count - 1] : null);
                    }

                    // 后处理
                    foreach (var f in filters)
                    {
                        f.Filter(log);
                    }

                    if (Logs.Count > 0)
                    {
                        var l = Logs[Logs.Count - 1];
                        Logs.RemoveAt(Logs.Count - 1);
                        Logs.Add(l);
                    }
                    Logs.Add(log);

                    // 统计
                    if (log.week_code != 0 && log.week_code != 6 && !d.IsNowDay())
                    {
                        TotalDay++;
                        FinishDay += (log.type_in == TimeType.Normal && log.type_out == TimeType.Normal) ? 1 : 0;
                    }
                }
                Ratio  = totalDay > 0 ? (float)finishDay / (float)totalDay : 1;
                Ratio *= 100;
            }
            catch (Exception _e) {
                MessageBox.Show(_e.Message);
                inwork = false;
            }

_end_:
            inwork = false;
        }
Пример #6
0
        async Task getLogAsync(int year, int month, int dayStart = 1, int dayEnd = 0)
        {
            if (string.IsNullOrEmpty(Name) || string.IsNullOrEmpty(Password))
            {
                goto _end_;
            }

            if (inwork)
            {
                return;
            }

            try {
                inwork = true;
                if (!await Fufu.loginAsync(Name, Password))
                {
                    goto _end_;
                }

                TotalDay  = 0;
                FinishDay = 0;
                Logs.Clear();
                // 开始为0,取整月
                if (dayEnd == 0)
                {
                    dayEnd = DateTime.DaysInMonth(year, month);
                }
                for (int i = dayEnd; i >= dayStart; i--)
                {
                    var log = await getLogAsync(new DateTime (year, month, i));

                    if (log == null)
                    {
                        continue;
                    }

                    if (Logs.Count > 0)
                    {
                        var l = Logs[Logs.Count - 1];
                        Logs.RemoveAt(Logs.Count - 1);
                        Logs.Add(l);
                    }
                    Logs.Add(log);
                    RaisePropertyChanged("Logs");

                    // 统计
                    if (log.week_code != 0 && log.week_code != 6 && !log._date.IsNowDay())
                    {
                        TotalDay++;
                        FinishDay += (log.type_in == TimeType.Normal && log.type_out == TimeType.Normal) ? 1 : 0;
                    }
                }
                Ratio  = totalDay > 0 ? (float)finishDay / (float)totalDay : 1;
                Ratio *= 100;
            }
            catch (Exception _e) {
                _e.Message.Alert();
                RaisePropertyChanged("Login_Failed");
                inwork = false;
            }

_end_:
            inwork = false;
            RaisePropertyChanged("Logs_End");
        }