Ejemplo n.º 1
0
        void QueryRules()
        {
            var service = new Service.AttendanceRuleService();

            service.OnQueryCompleted += (departs) => {
                if (departs != null)
                {
                    this.Dispatcher.BeginInvoke(new Action <AttendanceRule[]>((list) => {
                        rules.Clear();
                        AttendanceRule sel = null;
                        foreach (var v in list)
                        {
                            if (current != null && current.AttendanceRule != null && v.ID == current.AttendanceRule.ID)
                            {
                                sel = v;
                            }
                            rules.Add(v);
                        }

                        if (sel != null)
                        {
                            cboRule.SelectedItem = sel;
                        }
                        EnableUI(true);
                    }), new object[] { departs });
                }
            };
            service.Query((exp) => {
                EnableUI(true);
                MetroUIExtender.Alert(exp.Message);
            });
        }
        public void Save(AttendanceRule entity, Action <Exception> failFunc)
        {
            var url = "http://localhost:8888/api/AttendanceRule/Save";

            web.AsyncJsonPost(url, entity,
                              (response, cookies, exp) =>
            {
                if (null != response)
                {
                    var ret = JsonSerializer <AttendanceRule> .Deserialize(response);
                    if (ret != null)
                    {
                        if (null != OnSaveCompleted)
                        {
                            OnSaveCompleted(ret);
                        }
                    }
                    else
                    {
                        failFunc(new Exception("Failed in Save Object!"));
                    }
                }
                else if (null != exp)
                {
                    failFunc(exp);
                }
            });
        }
Ejemplo n.º 3
0
 public RuleEditWnd(AttendanceRule c)
 {
     InitializeComponent();
     current = c;
     InitUI();
     BindEvents();
 }
        public AttendanceRule Save(AttendanceRule entity)
        {
            if (entity == null)
            {
                return(null);
            }

            try
            {
                var rep = new AttendanceRuleRepository(db);
                if (entity.ID == Guid.Empty)
                {
                    entity.ID         = Guid.NewGuid();
                    entity.CreateUser = HttpContext.Current.User.Identity.Name;
                    entity.UpdateUser = HttpContext.Current.User.Identity.Name;
                    rep.Insert(entity);
                    db.SaveChanges();
                }
                else
                {
                    entity.UpdateTime = DateTime.Now;
                    entity.UpdateUser = HttpContext.Current.User.Identity.Name;
                    rep.Update(entity);
                    db.SaveChanges();
                }

                return(entity);
            }
            catch (Exception exp)
            {
                throw exp;
            }
        }
        public AttendanceRule Delete(AttendanceRule entiry)
        {
            var rep = new AttendanceRuleRepository(db);

            rep.Delete(entiry);
            db.SaveChanges();
            return(entiry);
        }
Ejemplo n.º 6
0
        private void Run()
        {
            if (DateTime.Now.Hour == 0 && DateTime.Now.Minute == 0)
            {
                Repository.UpdateTimerStatus();
            }

            var setting = Repository.GetTimerSetting();
            var now     = new DateTime(2017, 7, 26, DateTime.Now.Hour, DateTime.Now.Minute, DateTime.Now.Second);
            var set     = setting.FirstOrDefault(p => p.Status == 100 && p.StartTimer <= now && p.EndTimer >= now);

            if (set == null)
            {
                return;
            }

            ReadCurrent();
            ReadCurrent(connectionString);

            switch (set.TimerId)
            {
            case 1:      //上午
                AttendanceRule.Morning();
                break;

            case 2:      //中午第一次
                AttendanceRule.Noon();
                break;

            case 3:      //中午第二次
                AttendanceRule.Noon();
                break;

            case 4:      //下午
                AttendanceRule.Afternoon();
                break;

            case 5:      //早上迟到提醒
                AttendanceRule.MorningLate();
                break;

            case 6:      //更新全部
            case 7:
            case 8:
            case 9:
            case 10:
            case 11:
            case 12:
            case 13:
                ReadAll(connectionString);
                break;
            }

            Repository.UpdateTimerStatusById(set.TimerId);
        }
Ejemplo n.º 7
0
        public IActionResult DeleteAttendanceRule(long id)
        {
            AttendanceRule a = AttendanceRule_repo.Find(id);

            if (a == null)
            {
                return(NotFound());
            }
            AttendanceRule_repo.Delete(a);
            return(Ok());
        }
Ejemplo n.º 8
0
        private void OnButtonAddClick(object sender, RoutedEventArgs e)
        {
            var rule = new AttendanceRule();
            var wnd  = new RuleEditWnd(rule);

            wnd.OnClose += () => {
                Query();
                gridSub.Children.Clear();
                gridSub.Visibility  = Visibility.Collapsed;
                gridMain.Visibility = Visibility.Visible;
            };

            gridSub.Children.Clear();
            gridSub.Children.Add(wnd);
            gridMain.Visibility = Visibility.Collapsed;
            gridSub.Visibility  = Visibility.Visible;
        }
Ejemplo n.º 9
0
 public IActionResult UpdateAttendanceRule([FromBody] AttendanceRule model)
 {
     AttendanceRule_repo.Update(model);
     return(new OkObjectResult(new { AttendanceRuleID = model.AttendanceRuleId }));
 }