コード例 #1
0
        private void BtnDelete_Click(object sender, RoutedEventArgs e)
        {
            //获取鼠标选择的索引
            int num = dgUsers.SelectedIndex;

            if (num < 0)
            {
                MessageBox.Show("请选择要删除的行!");
            }
            else
            {
                //获取选中行
                AttendanceData user = (AttendanceData)dgUsers.SelectedValue;
                if (MessageBox.Show("是否删除" + user.Name + "的信息", "提示", MessageBoxButton.YesNo) == MessageBoxResult.Yes)
                {
                    //删除数据
                    if (bll.Delete(user.ID, 0))
                    {
                        MessageBox.Show("删除" + user.Name.Trim() + "成功");
                    }
                }
                //加载数据
                LoadData();
            }
        }
コード例 #2
0
        /// <summary>
        /// 显示考勤
        /// </summary>
        /// <param name="isDel"></param>
        /// <returns></returns>

        public List <AttendanceData> GetPartialAttendanceData(DateTime?StartDate, DateTime?EndDate) //,DateTime startTime,DateTime endTime)
        {
            //1 sql语句
            string sql = "SELECT * FROM Table_AttendanceData WHERE AttendanceDate BETWEEN @startTime AND  @endTime ";

            SqlParameter[] param =
            {
                new SqlParameter("@startTime", SqlDbType.Date),
                new SqlParameter("@endTime",   SqlDbType.Date)
            };
            param[0].Value = StartDate;
            param[1].Value = EndDate;
            //2 执行
            SqlDbHelper db = new SqlDbHelper();
            DataTable   dt = db.ExecuteDataTable(sql);
            //3 关系--》对象
            List <AttendanceData> attendances = new List <AttendanceData>();

            foreach (DataRow dr in dt.Rows)
            {
                //行转化成对象
                AttendanceData attendance = DataRowToAttendance(dr);
                attendances.Add(attendance);
            }
            return(attendances);
        }
コード例 #3
0
ファイル: AttendanceManager.cs プロジェクト: TimonYoon/Dev
    /// <summary> 웹서버에서 콜백받음 </summary>
    void OnWebServerResult(Dictionary <string, object> resultDataDic)
    {
        //if (isInitialized)
        //    return;


        if (resultDataDic.ContainsKey("attendance"))
        {
            attendanceDataList.Clear();
            JsonReader jsonReader = new JsonReader(JsonMapper.ToJson(resultDataDic["attendance"]));
            JsonData   jsonData   = JsonMapper.ToObject(jsonReader);

            attendanceData = new AttendanceData(jsonData);
            attendanceDataList.Add(attendanceData);
        }
        if (resultDataDic.ContainsKey("continuousAttendance"))
        {
            JsonReader jsonReader = new JsonReader(JsonMapper.ToJson(resultDataDic["continuousAttendance"]));
            JsonData   jsonData   = JsonMapper.ToObject(jsonReader);


            contAttendanceData = new AttendanceData(jsonData);
            attendanceDataList.Add(contAttendanceData);
        }
    }
コード例 #4
0
        private void BtnEdit_Click(object sender, RoutedEventArgs e)
        {
            //获取鼠标选择的索引
            int num = dgUsers.SelectedIndex;

            if (num < 0)
            {
                MessageBox.Show("请选择要修改的行!");
            }
            else
            {
                //获取选中行
                AttendanceData user = (AttendanceData)dgUsers.SelectedValue;
                //打开编辑窗口
                EditAttendancePage editAttendance = new EditAttendancePage();
                editAttendance.isAdd = false;
                //设置编号不能编辑
                editAttendance.txtID.IsReadOnly = true;
                //绑定数据
                editAttendance.gridUser.DataContext = user;

                //显示窗口
                editAttendance.ShowDialog();
            }
        }
コード例 #5
0
        public async Task AttendanceControllerGetAdmin()
        {
            var data   = new AttendanceApiDataHandler();
            var master = UserData.GetFirstProfile();
            var model  = AttendanceData.GetFirst();

            data.ResultParticipants = new List <ResultProfile>()
            {
                master
            };

            data.Result.Setup(m => m.Execute(It.IsAny <AttendanceById>())).Returns(model);

            var controller = new AttendanceController(data, Logic)
            {
                CurrentUser = AdminUser
            };
            var result = await controller.Get(AttendanceData.FirstId) as OkObjectResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <OkObjectResult>();

            var viewModel = result.Value as AttendanceViewModel;

            viewModel.Id.Should().Be(model.Id);
            viewModel.Name.Should().Be(model.Name);
            viewModel.AttendedWhen.Should().Be(model.AttendedWhen);

            data.HasExecuted.Should().BeTrue();
            data.Result.Verify(s => s.Execute(It.IsAny <Loader <Attendance> >()), Times.Once());
        }
コード例 #6
0
        public HttpResponseMessage UpdateAttendance([FromBody] AttendanceData data)
        {
            try
            {
                DataAccess _dal = new DataAccess();

                bool   result          = _dal.UpdateAttendanceData(data);
                string responseMessage = "Saved";
                if (result)
                {
                    responseMessage = JsonConvert.SerializeObject(responseMessage);
                    return(Request.CreateResponse(HttpStatusCode.OK, responseMessage));
                }
                else
                {
                    responseMessage = "Failed";
                    return(Request.CreateResponse(HttpStatusCode.NotAcceptable, responseMessage));
                }
            }

            catch (Exception ex)
            {
                return(Request.CreateResponse(HttpStatusCode.BadRequest, ex.Message));
            }
        }
コード例 #7
0
        public async Task AttendanceControllerPostEdit()
        {
            var data  = new AttendanceApiDataHandler();
            var model = AttendanceData.GetFirst();

            data.Result.Setup(m => m.Execute(It.IsAny <Loader <Attendance> >())).Returns(model);
            data.Result.Setup(m => m.Execute(It.IsAny <Persist <Attendance> >())).Returns(model);

            var controller = new AttendanceController(data, Logic)
            {
                CurrentUser = StandardUser
            };
            var viewModel = controller.Mapper.Map <AttendanceViewModel>(model);

            var result = await controller.Post(viewModel) as OkObjectResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <OkObjectResult>();
            result.Value.Should().NotBeNull();

            var check = result.Value as ConfirmViewModel;

            check.Identity.Should().Be(model.Id);

            data.HasExecuted.Should().BeTrue();
            data.HasCommitted.Should().BeTrue();
            data.Result.Verify(s => s.Execute(It.IsAny <Loader <Attendance> >()), Times.AtLeastOnce);
            data.Result.Verify(s => s.Execute(It.IsAny <Persist <Attendance> >()), Times.Once());
        }
コード例 #8
0
        public async Task AttendanceControllerPostAdd()
        {
            var data  = new AttendanceApiDataHandler();
            var model = AttendanceData.GetFirst();

            data.Result.Setup(m => m.Execute(It.IsAny <Persist <Attendance> >())).Returns(model);

            var controller = new AttendanceController(data, Logic)
            {
                CurrentUser = AdminUser
            };
            var viewModel = controller.Mapper.Map <AttendanceViewModel>(model);

            viewModel.Id = string.Empty;

            var result = await controller.Post(viewModel) as OkObjectResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <OkObjectResult>();
            result.Value.Should().NotBeNull();

            var check = result.Value as ConfirmViewModel;

            check.Identity.Should().Be(model.Id);

            viewModel.Participants.Count().Should().Be(0);
            viewModel.CanAttend.Should().BeFalse();

            data.HasExecuted.Should().BeTrue();
            data.HasCommitted.Should().BeTrue();
            data.Result.Verify(s => s.Execute(It.IsAny <Loader <Attendance> >()), Times.Never);
            data.Result.Verify(s => s.Execute(It.IsAny <Persist <Attendance> >()), Times.Once());
        }
コード例 #9
0
        public async Task AttendanceControllerFilter()
        {
            var data = new AttendanceApiDataHandler();
            var list = new List <AttendanceDisplay> {
                AttendanceData.GetFirstDisplay(false)
            };
            var filter = new AttendanceFilter {
                TenantRestrict = true
            };

            data.Result.Setup(m => m.Execute(It.IsAny <AttendanceDisplayByFilter>())).Returns(list);

            var controller = new AttendanceController(data, Logic)
            {
                CurrentUser = StandardUser
            };
            var result = await controller.Filter(filter) as OkObjectResult;

            result.Should().NotBeNull();
            result.Should().BeOfType <OkObjectResult>();
            result.Value.Should().NotBeNull();

            var check = result.Value as PagedResult <IEnumerable <AttendanceDisplay> >;

            check.Should().NotBeNull();
            check.Data.Count().Should().Be(list.Count);

            Assert.That(check.Data, Is.DeepEqualTo(list));

            data.HasExecuted.Should().BeTrue();
            data.Result.Verify(s => s.Execute(It.IsAny <AttendanceDisplayByFilter>()), Times.Once());
        }
コード例 #10
0
        public void Should_load_default_attandance_data_datein_dateout_if_null()
        {
            var attData   = new AttendanceData();
            var statement = "ifless(DateIn,DateOut,1,0)";

            Assert.AreEqual(0, calc.Calculate(statement, attData));
        }
        public void Should_reload_remark_as_constant()
        {
            var attData = new AttendanceData {
                Remark = 1
            };

            Assert.AreEqual(2, calc.Calculate("iif(Remark = abss,2,1)", attData));
        }
コード例 #12
0
        public async Task <List <StuAttendance> > GetStudentAttendance(string AdmissionNo, int MonthId)
        {
            AttendanceData obj      = new AttendanceData(csName);
            var            Result   = obj.GetStMonthlyAttendance(AdmissionNo, MonthId).ToList();
            var            Students = Mapper.Map <List <StAttendance>, List <StuAttendance> >(Result);

            return(Students);
        }
コード例 #13
0
        protected void SubmitNoteBtn_Click(object sender, EventArgs e)
        {
            Dictionary <int, AttendanceControl.ShortMarking> MarkingData = new Dictionary <int, AttendanceControl.ShortMarking>();

            LogInformation("Submitting Requested Notes.");

            Dictionary <int, AttendanceControl.AdditionalInfoRequest> request = (Dictionary <int, AttendanceControl.AdditionalInfoRequest>)Session["required_update_info"];

            AttendancePageInfo api = new AttendancePageInfo()
            {
                SectionId = this.SectionId, Name = ClassInfoLabel.Text, Date = AttendanceDate, Attendances = new List <AttendanceData>()
            };

            using (WebhostEntities db = new WebhostEntities())
            {
                foreach (TableRow row in UpdateTable.Rows)
                {
                    int     studentId = Convert.ToInt32(((HiddenField)row.Cells[1].Controls[0]).Value);
                    Student student   = db.Students.Find(studentId);
                    String  Notes     = ((TextBox)row.Cells[1].Controls[1]).Text;
                    int     markId    = request[studentId].markingId;
                    MarkingData.Add(studentId, new AttendanceControl.ShortMarking()
                    {
                        markId = markId, notes = Notes
                    });
                    AttendanceData atd = new AttendanceData()
                    {
                        StudentId = studentId,
                        Name      = String.Format("{0} {1}", student.FirstName, student.LastName),
                        Marking   = db.GradeTableEntries.Find(markId).Name
                    };
                    ((List <AttendanceData>)api.Attendances).Add(atd);
                }
            }
            LogCurrentData(api);

            request.Clear();
            request = AttendanceControl.SubmitAttendance(SectionId, MarkingData, user.ID, AttendanceDate);
            if (request.Count != 0)
            {
                Session["required_update_info"] = request;
                Response.Redirect("~/Mobile/UpdateInformation.aspx");
            }
            else
            {
                Session["required_update_info"] = null;
                SectionId      = -1;
                AttendanceDate = DateTime.Today;
                if (this.IsRedirect)
                {
                    Redirect(this.RedirectedUrl);
                }
                else
                {
                    Redirect("~/Mobile/Attendance.aspx");
                }
            }
        }
コード例 #14
0
        public void Should_get_isnull_true_if_datein_dateout_eq_null()
        {
            var attData    = new AttendanceData();
            var statement1 = "IsNullDateIn";
            var statement2 = "IsNullDateOut";

            Assert.AreEqual(1, calc.Calculate(statement1, attData));
            Assert.AreEqual(1, calc.Calculate(statement2, attData));
        }
コード例 #15
0
        public void Should_transform_datetime_to_dotnet_context()
        {
            var attData = new AttendanceData {
                DateIn = new DateTime(2020, 1, 1, 7, 0, 0), DateOut = new DateTime(2020, 1, 3, 17, 0, 0)
            };
            var statement = "iif((DateOut > DateIn) AND (TimeOfDateOut > 0) AND IsNullDateOut=0, 1, 0)";

            Assert.AreEqual(1, calc.Calculate(statement, attData));
        }
コード例 #16
0
        public void Should_load_attandance_data_datein_dateout()
        {
            var attData = new AttendanceData {
                DateIn = new DateTime(2020, 1, 1, 7, 0, 0), DateOut = new DateTime(2020, 1, 3, 17, 0, 0)
            };
            var statement = "ifless(DateIn,DateOut,1,0)";

            Assert.AreEqual(1, calc.Calculate(statement, attData));
        }
コード例 #17
0
        public void Should_beable_to_get_time_of_datein_and_date_out()
        {
            var attData = new AttendanceData {
                DateIn = new DateTime(2020, 1, 1, 7, 0, 0), DateOut = new DateTime(2020, 1, 3, 17, 0, 0)
            };
            var statement = "TimeOfDateOut-TimeOfDateIn";
            var diff      = TimeSpan.FromHours(10).Ticks;

            Assert.AreEqual(diff, calc.Calculate(statement, attData));
        }
コード例 #18
0
ファイル: GeoXPage.xaml.cs プロジェクト: kgbuddhima/GeoFenceX
 /// <summary>
 /// Send attendance data to api
 /// </summary>
 /// <param name="attendance"></param>
 private async Task UpdateAttendanceAsync(AttendanceData attendance)
 {
     try
     {
         await _service.UpdateAttendenceAsync(attendance);
     }
     catch (Exception ex)
     {
         // throw;
     }
 }
コード例 #19
0
        private AttendanceData DataRowToAttendance(DataRow dr)
        {
            AttendanceData attendance = new AttendanceData();

            attendance.ID             = Convert.ToInt32(dr["ID"]);
            attendance.Name           = Convert.ToString(dr["Name"]);
            attendance.AttendanceDate = Convert.ToDateTime(dr["AttendanceDate"]);
            attendance.Type           = Convert.ToString(dr["Type"]);
            attendance.Remark         = Convert.ToString(dr["Remark"]);
            return(attendance);
        }
コード例 #20
0
        public static async Task <AttendanceData> ToAttendanceDataAsync(this Attendance attendance, IStaticDataRepository staticData)
        {
            var transformed = new AttendanceData();

            if (attendance != null)
            {
                transformed.DateIn  = attendance.DateIn;
                transformed.DateOut = attendance.DateOut;
                transformed.Remark  = await FindRemarkIdAsync(staticData, attendance.Remark);
            }
            return(transformed);
        }
コード例 #21
0
        protected override void SetupDatabase(IDocumentStore store)
        {
            store.ExecuteIndex(new AttendanceIndex());

            using var session = store.OpenSession();
            session.Store(AttendanceData.GetFirst());
            session.Store(MeetingData.GetFirst());
            session.Store(UserData.GetFirst());
            session.SaveChanges();

            WaitForIndexing(store);
        }
コード例 #22
0
        public void Should_load_attandance_data()
        {
            var attData = new AttendanceData {
                Regular = 1, Remark = 2
            };
            var statementFalse = "iif(Regular=2,1,2)";

            Assert.AreEqual(2, calc.Calculate(statementFalse, attData));
            var statementAttTrue = "iif(Regular=1 && Remark=2,1,2)";

            Assert.AreEqual(1, calc.Calculate(statementAttTrue, attData));
        }
コード例 #23
0
        public void Should_get_isnull_not_true_if_datein_dateout_eq_not_null()
        {
            var attData = new AttendanceData()
            {
                DateIn = new DateTime(2020, 1, 1, 7, 0, 0)
            };
            var statement1 = "IsNullDateIn";
            var statement2 = "IsNullDateOut";

            Assert.AreEqual(0, calc.Calculate(statement1, attData));
            Assert.AreEqual(1, calc.Calculate(statement2, attData));
        }
コード例 #24
0
        public void Should_load_attandance_load_formulas()
        {
            var attData = new AttendanceData {
                Regular = 1, Remark = 2
            };
            var attFormula = new AttendanceFormula {
                OT = "iif(Regular=2,1,2)", OT1 = "iif(Regular=1 && Remark=2,1,2)"
            };
            AttendanceCalculationResult result = calc.Calculate(attFormula, attData);

            Assert.AreEqual(2, result.OT);
            Assert.AreEqual(1, result.OT1);
        }
コード例 #25
0
        public async Task AttendanceByIdDataTest()
        {
            using var store   = GetDocumentStore();
            using var session = store.OpenAsyncSession();
            var loader = new AttendanceById()
            {
                Session = session, Id = AttendanceData.FirstId
            };
            await loader.Execute();

            loader.Result.Should().NotBeNull();
            loader.Result.Id.Should().Be(AttendanceData.FirstId);
            Assert.That(loader.Result, Is.DeepEqualTo(AttendanceData.GetFirst()));
        }
コード例 #26
0
ファイル: GeoXPage.xaml.cs プロジェクト: kgbuddhima/GeoFenceX
        public GeoXPage()
        {
            InitializeComponent();

            _service            = new GeoService();
            model               = new GeoLocationsStatusViewModel();
            this.BindingContext = model;

            try
            {
                GetUserregionCollection();
                userPlacesCollection = model.LocationStatusCollection;
            }
            catch (Exception ex)
            {
                DisplayAlert("Error loading", ex.Message, "OK");
            }


            listView.ItemsSource = userPlacesCollection;

            /// Catch the region status change and send Attendance record to API
            MessagingCenter.Subscribe <GeofenceResult>(this, "region", async(region) =>
            {
                // await DisplayAlert("Region", region.TransitionName, "OK", "Cancel");
                Region p = new Region()
                {
                    Name            = region.TransitionName.ToString() + "|" + region.RegionId,
                    Latitude        = region.Latitude,
                    Longitude       = region.Longitude,
                    LastEnteredTime = (DateTime)region.LastEnterTime,
                    LastExitedTime  = (DateTime)region.LastExitTime
                };
                // add region status resut to list
                model.LocationStatusCollection.Add(p);

                AttendanceData att = new AttendanceData()
                {
                    Name           = region.RegionId,
                    Latitude       = region.Latitude,
                    Longitude      = region.Longitude,
                    TransitionName = region.TransitionName,
                    TransitionTime = region.TransitionName == GeofenceTransition.Exited.ToString() ? p.LastExitedTime:p.LastEnteredTime,
                    UserId         = 1
                };
                // send record to API
                await UpdateAttendanceAsync(att);
            });
        }
コード例 #27
0
ファイル: MasterCoverageTest.cs プロジェクト: rog1039/crux
        public void AttendanceMasterTest()
        {
            var config = new MapperConfiguration(cfg =>
            {
                cfg.CreateMap <Attendance, AttendanceMaster>();
                cfg.CreateMap <AttendanceMaster, Attendance>();
            });

            var mapper   = new Mapper(config);
            var master   = mapper.Map <AttendanceMaster>(AttendanceData.GetFirst());
            var document = mapper.Map <Attendance>(master);

            master.Should().NotBeNull();
            document.Should().NotBeNull();
        }
コード例 #28
0
        public void Should_calcuate_absent_day()
        {
            var attData = new AttendanceData {
                Classification = "CLS01", Regular = 1, Remark = 3
            };
            var attFormula = new AttendanceFormula {
                AbsentDay = mAbsenDayFormula, OT = "iif(Regular=2,1,2)", OT1 = "iif(Regular=1 && Remark=2,1,2)"
            };
            var classMock = new Mock <IAttendanceClassification>();

            classMock.Setup(m => m.LoadFormulasById("CLS01")).Returns(attFormula);
            AttendanceCalculationResult result = calc.Calculate(classMock.Object, attData);

            Assert.AreEqual(0.5, result.AbsentDay);
        }
コード例 #29
0
        public void Should_load_attandance_load_formulas()
        {
            var attData = new AttendanceData {
                Classification = "CLS01", Regular = 1, Remark = 2
            };
            var attFormula = new AttendanceFormula {
                OT = "iif(Regular=2,1,2)", OT1 = "iif(Regular=1 && Remark=2,1,2)"
            };
            var classMock = new Mock <IAttendanceClassification>();

            classMock.Setup(m => m.LoadFormulasById("CLS01")).Returns(attFormula);
            AttendanceCalculationResult result = calc.Calculate(classMock.Object, attData);

            Assert.AreEqual(2, result.OT);
            Assert.AreEqual(1, result.OT1);
        }
コード例 #30
0
ファイル: AttendanceUtil.cs プロジェクト: qooponsy/backup
        public String getInputFileData()
        {
            var errMsg = new StringBuilder();

            try
            {
                // 格納用リストの初期化
                aList = null;
                aList = new List<AttendanceData>();

                // 設定ファイル読込
                var sr = new StreamReader(SaveFilePath);
                var headerFlg = true;

                // 1行ずつ読込
                while (sr.Peek() > -1)
                {
                    if (headerFlg)
                    {
                        // ヘッダ行はスキップ
                        headerFlg = false;
                    }
                    else
                    {
                        // 勤怠入力データを取得
                        var line = sr.ReadLine();
                        var items = line.Split('\t');

                        var input = new AttendanceData();
                        input.StartTime = items[0];
                        input.EndTime = items[1];
                        input.WorkingHours = items[2];
                        input.Remarks = items[3];

                        aList.Add(input);
                    }
                }

            }
            catch (Exception ex)
            {
                errMsg.AppendLine("勤怠ファイルの読込に失敗しました。");
                errMsg.AppendLine(CommonUtil.getErrorMessage(ex));
            }

            return errMsg.ToString();
        }