Beispiel #1
0
        void Rl_Click(object sender, EventArgs e)
        {
            RelativeLayout rlValue = (RelativeLayout)sender;
            TextView       tvValue = (TextView)rlValue.GetChildAt(0);

            int IDdrug = (int)rlValue.GetTag(Resource.String.IDdrug);
            int IDinfo = (int)rlValue.GetTag(Resource.String.IDinfo);

//			string message = string.Format(@"Click to IDdrug:{0}, IDinfo:{0}", IDdrug, IDinfo);

//			Toast.MakeText(Activity,  message, ToastLength.Short).Show();

            string value = AttendanceResultManager.GetResultValue(newAttendanceResults, IDinfo, IDdrug);

            value = AttendanceResult.InvertStringBool(value);

            AttendanceResultManager.SetResultValue(newAttendanceResults, IDinfo, IDdrug, value);

            if (string.IsNullOrEmpty(value) || value.Equals(@"N"))
            {
                tvValue.SetTextAppearance(Activity, Resource.Style.text_danger);
                rlValue.SetBackgroundColor(Android.Graphics.Color.LightPink);
            }
            else
            {
                tvValue.SetTextAppearance(Activity, Resource.Style.text_success);
                rlValue.SetBackgroundColor(Android.Graphics.Color.LightGreen);
            }
            tvValue.Text = AttendanceResult.StringBoolToRussian(value);
            AttendanceResultManager.SetCurrentAttendanceResults(newAttendanceResults);
        }
Beispiel #2
0
        public void Check(IEnumerable <CheckInOut> logs, IEnumerable <FormInfoExtend1> leaves, AttendanceTime time)
        {
            var amLog = logs.FirstOrDefault(e => e.CreateTime >= time.AMBeginTime && e.CreateTime <= time.AMEndTime);

            if (amLog != null)
            {
                AMResult = AttendanceResult.Normal;
            }
            else if (leaves.Any(e => e.ScheduleBeginTime <= time.AMBeginTime && e.ScheduleEndTime >= time.AMEndTime))
            {
                AMResult = AttendanceResult.Leave;
            }
            else
            {
                AMResult = AttendanceResult.Absent;
            }
            var pmLog = logs.LastOrDefault(e => e.CreateTime >= time.PMBeginTime && e.CreateTime <= time.PMEndTime);

            if (pmLog != null)
            {
                PMResult = AttendanceResult.Normal;
            }
            else if (leaves.Any(e => e.ScheduleBeginTime <= time.AMBeginTime && e.ScheduleEndTime >= time.AMEndTime))
            {
                PMResult = AttendanceResult.Leave;
            }
            else
            {
                PMResult = AttendanceResult.Absent;
            }
        }
        public AttendanceResult Check(string groupName, IChannel channel)
        {
            var group = _groupStorage.GetGroup(groupName);

            if (group == null)
            {
                return new AttendanceResult
                       {
                           Errors = new List <string> {
                               $"The class {groupName} does not exist"
                           }
                       }
            }
            ;

            var users = GetUsers(channel.GetUsersAsync());

            var output = new AttendanceResult();

            foreach (var member in group.Members)
            {
                if (users.Any(u => u.Username == member.Username))
                {
                    output.Present.Add(member);
                }
                else
                {
                    output.Missing.Add(member);
                }
            }

            return(output);
        }
Beispiel #4
0
        public virtual async Task <ActionResult> Participants(string EventId)
        {
            // Event Id must be an integer and found
            //
            Int32 eventId = 0;

            if (!Int32.TryParse(EventId, out eventId))
            {
                eventId = 0;
            }
            if (eventId == 0)
            {
                return(new HttpStatusCodeResult(400, "Invalid event Id"));
            }

            // Retrieve participants and format into appropriate view model
            //
            var attendings = await RaceDayClient.GetEventDetail(eventId);

            List <EventParticipant> participants = new List <EventParticipant>();

            foreach (var user in attendings.attendees)
            {
                participants.Add(EventParticipant.FromJson(user));
            }

            // return the rendered view with participants in it
            //
            AttendanceResult result = new AttendanceResult();

            result.Attendees = RenderPartialViewToString(MVC.Shared.Views.Partials._ParticipantList, participants);

            return(Json(result));
        }
Beispiel #5
0
        public virtual async Task <ActionResult> Attending(String EventId, String ClassName)
        {
            // Event Id must be an integer and found
            //
            Int32 eventId = 0;

            if (!Int32.TryParse(EventId, out eventId))
            {
                eventId = 0;
            }
            if (eventId == 0)
            {
                return(new HttpStatusCodeResult(400, "Invalid event Id"));
            }

            // ClassName must be recognized
            //
            if ((ClassName != "glyphicon-check") && (ClassName != "glyphicon-unchecked"))
            {
                return(new HttpStatusCodeResult(400, "Unrecognized class name"));
            }

            EventDetail eventDetail;

            // Switch the attendance
            //
            AttendanceResult result = new AttendanceResult();

            if (ClassName == "glyphicon-check")
            {
                await RaceDayClient.RemoveUserFromEvent(eventId);

                eventDetail = await RaceDayClient.GetEventDetail(eventId);

                result.Button = RenderPartialViewToString(MVC.Shared.Views.Partials._NotAttendingButton, EventInfo.CopyFromEventService(false, eventDetail));
            }
            else
            {
                await RaceDayClient.AddUserToEvent(eventId);

                eventDetail = await RaceDayClient.GetEventDetail(eventId);

                result.Button = RenderPartialViewToString(MVC.Shared.Views.Partials._AttendingButton, EventInfo.CopyFromEventService(true, eventDetail));
            }

            // Rebind the participant list with the change
            //
            List <EventParticipant> participants = new List <EventParticipant>();

            foreach (var user in eventDetail.attendees)
            {
                participants.Add(EventParticipant.FromJson(user));
            }

            result.Attendees = RenderPartialViewToString(MVC.Shared.Views.Partials._ParticipantList, participants);
            return(Json(result));
        }
Beispiel #6
0
        protected override Object GetItemFromInput()
        {
            AttendanceResult ar = UpdatingItem as AttendanceResult;

            if (IsAdding)
            {
                return(null);
            }
            ar.Result   = (AttendanceResultCode)cmbShiftResult.SelectedIndex;
            ar.Modifier = Operator.CurrentOperator.Name;
            ar.Memo     = txtMemo.Text;
            return(ar);
        }
        public CommandResult Update(AttendanceResult info)
        {
            AttendanceResult org = ProviderFactory.Create <IAttendanceResultProvider>(_RepoUri).GetByID(info.ID).QueryObject;

            if (org != null)
            {
                return(ProviderFactory.Create <IAttendanceResultProvider>(_RepoUri).Update(info, org));
            }
            else
            {
                return(new CommandResult(ResultCode.NoRecord, ResultCodeDecription.GetDescription(ResultCode.NoRecord)));
            }
        }
 protected override FrmDetailBase GetDetailForm()
 {
     if (GridView.SelectedRows.Count == 1)
     {
         FrmShiftResultDetail frm = new FrmShiftResultDetail();
         AttendanceResult     sar = GridView.SelectedRows[0].Tag as AttendanceResult;
         frm.DeptName = departmentTreeview1.GetDepartmentName(sar.StaffID);
         Staff s = departmentTreeview1.GetStaff(sar.StaffID);
         frm.Staff = s;
         return(frm);
     }
     return(null);
 }
        public virtual ActionResult Participants(string EventId)
        {
            Repository repository = new Repository();

            // Current user must be logged in
            //
            if (FacebookUser.CurrentUser == null)
            {
                return(new HttpStatusCodeResult(400, "User authorization not found"));
            }

            // Event Id must be an integer and found
            //
            Int32 eventId = 0;

            if (!Int32.TryParse(EventId, out eventId))
            {
                eventId = 0;
            }
            if (eventId == 0)
            {
                return(new HttpStatusCodeResult(400, "Invalid event Id"));
            }

            Event currentEvent = repository.GetEventById(eventId);

            if (currentEvent == null)
            {
                return(new HttpStatusCodeResult(400, "Event record not found"));
            }

            // Retrieve participants and format into appropriate view model
            //
            var attendings = repository.GetUsersForEvent(currentEvent.EventId);
            List <EventParticipant> participants = new List <EventParticipant>();

            foreach (MFUser user in attendings)
            {
                participants.Add(EventParticipant.FromUser(user, FacebookUser.CurrentUser.access_token));
            }

            // return the rendered view with participants in it
            //
            AttendanceResult result = new AttendanceResult();

            result.Attendees = RenderPartialViewToString(MVC.Shared.Views.Partials._ParticipantList, participants);

            return(Json(result));
        }
Beispiel #10
0
        protected override void ItemShowing()
        {
            txtDept.Text = DeptName;
            if (Staff != null)
            {
                txtCertificate.Text = Staff.Certificate;
                txtName.Text        = Staff.Name;
            }
            AttendanceResult ar = UpdatingItem as AttendanceResult;

            txtShiftDate.Text = ar.ShiftDate.ToLongDateString();
            txtShiftTime.Text = ar.StartTime.ToString("HH:mm") + "--" + ar.EndTime.ToString("HH:mm");
            txtRealTime.Text  = (ar.OnDutyTime != null ? ar.OnDutyTime.Value.ToString("HH:mm") : new string(' ', 5)) + "--" +
                                (ar.OffDutyTime != null ? ar.OffDutyTime.Value.ToString("HH:mm") : new string(' ', 5));
            cmbShiftResult.SelectedIndex = (int)ar.Result;
            txtOperator.Text             = ar.Modifier;
            txtMemo.Text = ar.Memo;
        }
 private string AbsentItemsDescr(AttendanceResult sar)
 {
     if (sar.AbsentItems != null && sar.AbsentItems.Count > 0)
     {
         string temp = string.Empty;
         for (int i = 0; i < sar.AbsentItems.Count; i++)
         {
             if (i > 0)
             {
                 temp += ",";
             }
             AttendanceDuration dur = AttendanceRules.Current.GetDuarationFrom(sar.AbsentItems[i].Duration, true);
             temp += string.Format("{0} {1} {2}", sar.AbsentItems[i].Category, dur.Value, dur.Unit);
         }
         return(temp);
     }
     return(null);
 }
Beispiel #12
0
        /// <summary>
        /// 手动签到
        /// </summary>
        /// <param name="TeaNo">教师编号</param>
        /// <param name="StuNo">学生编号</param>
        /// <param name="CourseNo">课程编号</param>
        public AttendanceResult ManualCheckIn(string TeaNo, string StuNo, string CourseNo, string CheckStatus)
        {
            AttendanceResult result      = new AttendanceResult();
            DateTime         currentTime = Convert.ToDateTime(Infrastructure.Extended.DatetimeExtened.GetNetDateTime());
            //今天星期几
            string week          = ((float)currentTime.DayOfWeek).ToString(CultureInfo.InvariantCulture);
            Course teacherCourse = CourseService.GetTeacherCourse(TeaNo).FirstOrDefault(u => u.Week == week);

            if (teacherCourse == null) //教师今日没有该课程
            {
                result.ResultCode = ResultCode.Error;
                result.Message    = "教师今日没有该课程";
                return(result);
            }
            string attendanceId = $"{currentTime:yyyyMMdd}.{teacherCourse.Id}";

            result = CheckIn(attendanceId, StuNo, CourseNo, CheckStatus);
            return(result);
        }
        protected override void ShowItemInGridViewRow(DataGridViewRow row, object item)
        {
            AttendanceResult sar = item as AttendanceResult;

            row.Tag = sar;
            row.Cells["colDept"].Value              = departmentTreeview1.GetDepartmentName(sar.StaffID);
            row.Cells["colStaff"].Value             = sar.StaffName;
            row.Cells["colShift"].Value             = sar.ShiftName;
            row.Cells["colShiftDate"].Value         = sar.ShiftDate.ToString("yyyy-MM-dd");
            row.Cells["colShiftOnDuty"].Value       = sar.StartTime.ToString("HH:mm:ss");
            row.Cells["colShiftOffDuty"].Value      = sar.EndTime.ToString("HH:mm:ss");
            row.Cells["colOnduty"].Value            = sar.OnDutyTime == null ? string.Empty : sar.OnDutyTime.Value.ToString("HH:mm:ss");
            row.Cells["colOnduty"].Style.ForeColor  = (sar.Result == AttendanceResultCode.Late || sar.Result == AttendanceResultCode.LateEarly) ? Color.Red : Color.Black;
            row.Cells["colOffDuty"].Value           = sar.OffDutyTime == null ? string.Empty : sar.OffDutyTime.Value.ToString("HH:mm:ss");
            row.Cells["colOffDuty"].Style.ForeColor = (sar.Result == AttendanceResultCode.LeaveEarly || sar.Result == AttendanceResultCode.LateEarly) ? Color.Red : Color.Black;
            row.Cells["colShiftTime"].Value         = AttendanceRules.Current.GetDuarationFrom(sar.ShiftTime, false).Value;
            row.Cells["colPresent"].Value           = AttendanceRules.Current.GetDuarationFrom(sar.Present, false).Value;
            row.Cells["colResult"].Value            = sar.ResultDescr;
            row.Cells["colResult"].Style.ForeColor  = sar.Result == AttendanceResultCode.OK ? Color.Blue : Color.Red;
            row.Cells["colMemo"].Value              = (!string.IsNullOrEmpty(sar.ShiftID)) ? AbsentItemsDescr(sar) : sar.Category;
        }
Beispiel #14
0
        /// <summary>
        /// 教师发起签到
        /// </summary>
        /// <param name="TeaNo">教工编号</param>
        /// <param name="CourseNo">课程编号</param>
        /// <returns></returns>
        public ActionResult InitiatedCheckIn(string TeaNo, string CourseNo)
        {
            if (TeaNo == null || CourseNo == null)
            {
                return(null);
            }
            using (var tran = AttendanceService.dal.dbContext.Database.BeginTransaction())
            {
                AttendanceResult result = AttendanceService.InitiatedAttendance(TeaNo, CourseNo);
                try
                {
                    if (result.ResultCode == ResultCode.Ok)
                    {
                        string HostIP = IPUtils.GetHostAddresse();
                        string data   = $"http://{HostIP}:8080/api/Attendance/StudentCheckIn?AttendanceId={result.AttendanceId}&CourseNo={CourseNo}&StuNo=";
                        byte[] bytes  = QRCodeHelper.GetQRCode(data);

                        var    room         = RoomService.GetEntity(u => u.F_EnCode == result.RoomNo).FirstOrDefault();
                        string mac          = room?.F_ComputeMac;
                        string connectionId = Cache.GetCache <string>(mac);

                        GlobalHost.ConnectionManager.GetHubContext <QRCodeHub>().Clients.Client(connectionId)
                        .ReciverImg(bytes);
                        tran.Commit();
                    }
                }
                catch (Exception exception)
                {
                    ExceptionHelper.AddException(exception);
                    result.ResultCode   = ResultCode.Error;
                    result.Message      = "教室网页已断开连接";
                    result.AttendanceId = null;
                    tran.Rollback();
                }
                return(Json(result, JsonRequestBehavior.AllowGet));
            }
        }
 public CommandResult Delete(AttendanceResult info)
 {
     return(ProviderFactory.Create <IAttendanceResultProvider>(_RepoUri).Delete(info));
 }
Beispiel #16
0
        void RefreshTable()
        {
            table.RemoveAllViews();

            TableRow.LayoutParams lpRow = new TableRow.LayoutParams();
            lpRow.Height  = TableLayout.LayoutParams.WrapContent;
            lpRow.Width   = TableLayout.LayoutParams.WrapContent;
            lpRow.Gravity = GravityFlags.Center;

            //header
            TableRow trHeader = new TableRow(Activity);
            TextView tvHDrug  = (TextView)layoutInflater.Inflate(Resource.Layout.DrugInfoDrugItem, null);

            //tvHDrug.SetTextAppearance (Activity, Resource.Style.text_header_large);
            tvHDrug.Text             = "Препараты";
            tvHDrug.LayoutParameters = lpRow;
            ((TableRow.LayoutParams)tvHDrug.LayoutParameters).SetMargins(0, 0, ToDIP(1), 0);
            tvHDrug.SetBackgroundColor(Android.Graphics.Color.White);
            trHeader.AddView(tvHDrug);

            int i = 0;

            TableRow.LayoutParams lpValue = new TableRow.LayoutParams();
            lpValue.Height  = TableLayout.LayoutParams.WrapContent;
            lpValue.Width   = TableLayout.LayoutParams.WrapContent;
            lpValue.Gravity = GravityFlags.Center;
            lpValue.SetMargins(ToDIP(1), ToDIP(1), ToDIP(1), ToDIP(1));

            foreach (var drug in drugs)
            {
                i++;

                TableRow trRow  = new TableRow(Activity);
                TextView tvDrug = (TextView)layoutInflater.Inflate(Resource.Layout.DrugInfoDrugItem, null);
                tvDrug.Gravity = GravityFlags.CenterVertical;
                tvDrug.SetTextAppearance(Activity, Resource.Style.text_row_large);
                tvDrug.Text             = string.Format(@"{0}: {1}", i, drug.fullName);
                tvDrug.LayoutParameters = lpRow;
                tvDrug.SetBackgroundColor(Android.Graphics.Color.White);
                trRow.AddView(tvDrug);

                foreach (var info in infos)
                {
                    if (trHeader.Parent == null)
                    {
                        TextView tvHInfo = (TextView)layoutInflater.Inflate(Resource.Layout.DrugInfoValueHeader, null);
                        tvHInfo.Text = info.name;
                        tvHInfo.SetBackgroundColor(Android.Graphics.Color.White);
                        trHeader.AddView(tvHInfo);
                    }

                    RelativeLayout rlValue = new RelativeLayout(Activity);
                    rlValue.SetGravity(GravityFlags.Center);
                    rlValue.SetMinimumHeight(ToDIP(64));
                    rlValue.SetMinimumWidth(ToDIP(64));
                    rlValue.LayoutParameters = lpValue;

                    rlValue.SetTag(Resource.String.IDinfo, info.id);
                    rlValue.SetTag(Resource.String.IDdrug, drug.id);
//					rlValue.SetTag (Resource.String.IDattendance, attendace.id);

                    string value = AttendanceResultManager.GetResultValue(newAttendanceResults, info.id, drug.id);

                    if (info.valueType == @"number")
                    {
                        RelativeLayout.LayoutParams nlpValue = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.MatchParent);
                        nlpValue.AddRule(LayoutRules.CenterInParent);
                        nlpValue.SetMargins(ToDIP(1), ToDIP(1), ToDIP(1), ToDIP(1));

                        EditText evValue = new EditText(Activity)
                        {
                            LayoutParameters = nlpValue
                        };
                        evValue.SetMinimumWidth(ToDIP(64));
                        evValue.SetMaxWidth(ToDIP(64));
                        evValue.InputType = Android.Text.InputTypes.ClassNumber;
                        evValue.Text      = value.Equals(@"N") ? string.Empty : value;
                        rlValue.AddView(evValue);
                        evValue.AfterTextChanged += NumberValue_AfterTextChanged;
                    }

                    if (info.valueType == @"decimal")
                    {
                        RelativeLayout.LayoutParams dlpValue = new RelativeLayout.LayoutParams(RelativeLayout.LayoutParams.WrapContent, RelativeLayout.LayoutParams.MatchParent);
                        dlpValue.AddRule(LayoutRules.CenterInParent);
                        dlpValue.SetMargins(ToDIP(1), ToDIP(1), ToDIP(1), ToDIP(1));

                        EditText evValue = new EditText(Activity)
                        {
                            LayoutParameters = dlpValue
                        };
                        evValue.SetMinimumWidth(ToDIP(64));
                        evValue.SetMaxWidth(ToDIP(64));
                        evValue.InputType = Android.Text.InputTypes.NumberFlagDecimal;
                        evValue.Text      = value.Equals(@"N") ? string.Empty : value;
                        rlValue.AddView(evValue);
                        evValue.AfterTextChanged += DecimalValue_AfterTextChanged;
                    }

                    if (info.valueType == @"boolean")
                    {
                        rlValue.Click += Rl_Click;

                        TextView tvValue = new TextView(Activity);
                        tvValue.Gravity = GravityFlags.Center;
                        if (string.IsNullOrEmpty(value) || value.Equals(@"N"))
                        {
                            tvValue.SetTextAppearance(Activity, Resource.Style.text_danger);
                            rlValue.SetBackgroundColor(Android.Graphics.Color.LightPink);
                        }
                        else
                        {
                            tvValue.SetTextAppearance(Activity, Resource.Style.text_success);
                            rlValue.SetBackgroundColor(Android.Graphics.Color.LightGreen);
                        }
                        tvValue.Text = AttendanceResult.StringBoolToRussian(value);
                        rlValue.AddView(tvValue);
                    }

                    trRow.AddView(rlValue);
                }

                if (trHeader.Parent == null)
                {
                    table.AddView(trHeader);
                    table.AddView(GetDelim(Android.Graphics.Color.Black));
                }
                table.AddView(trRow);
                table.AddView(GetDelim(Android.Graphics.Color.Brown));
            }
        }
Beispiel #17
0
        public virtual ActionResult Attending(String EventId, String ClassName)
        {
            Repository repository = new Repository();

            // Current user must be logged in and found
            //
            if (FacebookUser.CurrentUser == null)
            {
                return(new HttpStatusCodeResult(400, "User authorization not found"));
            }

            MFUser currentUser = repository.GetUserById(FacebookUser.CurrentUser.id);

            if (currentUser == null)
            {
                return(new HttpStatusCodeResult(400, "User record not found"));
            }

            // Event Id must be an integer and found
            //
            Int32 eventId = 0;

            if (!Int32.TryParse(EventId, out eventId))
            {
                eventId = 0;
            }
            if (eventId == 0)
            {
                return(new HttpStatusCodeResult(400, "Invalid event Id"));
            }

            Event currentEvent = repository.GetEventById(eventId);

            if (currentEvent == null)
            {
                return(new HttpStatusCodeResult(400, "Event record not found"));
            }

            // ClassName must be recognized
            //
            if ((ClassName != "glyphicon-check") && (ClassName != "glyphicon-unchecked"))
            {
                return(new HttpStatusCodeResult(400, "Unrecognized class name"));
            }

            // Switch the attendance
            //
            AttendanceResult result = new AttendanceResult();

            if (ClassName == "glyphicon-check")
            {
                repository.RemoveUserFromEvent(currentUser, currentEvent);
                repository.SaveChanges();

                result.Button = RenderPartialViewToString(MVC.Shared.Views.Partials._NotAttendingButton, EventInfo.CopyFromEvent(false, currentEvent));
            }
            else
            {
                repository.AddUserToEvent(currentUser, currentEvent, AttendingEnum.Attending);
                repository.SaveChanges();

                result.Button = RenderPartialViewToString(MVC.Shared.Views.Partials._AttendingButton, EventInfo.CopyFromEvent(true, currentEvent));
            }

            // Rebind the participant list with the change
            //
            result.Attendees = String.Empty;
            return(Json(result));
        }
Beispiel #18
0
        /// <summary>
        /// 学生进行签到
        /// </summary>
        /// <param name="AttendanceId">签到ID</param>
        /// <param name="StuNo">学生学号</param>
        /// <param name="CourseNo">课程编号</param>
        public ActionResult StudentCheckIn(string AttendanceId, string StuNo, string CourseNo)
        {
            AttendanceResult result = AttendanceService.CheckIn(AttendanceId, StuNo, CourseNo);

            return(Json(result, JsonRequestBehavior.AllowGet));
        }
Beispiel #19
0
        /// <summary>
        /// 学生签到
        /// </summary>
        /// <param name="StuNo">学号</param>
        /// <param name="CourseNo">课程编号</param>
        /// <param name="CheckStatus">签到状态</param>
        /// <returns></returns>
        public AttendanceResult CheckIn(string AttendanceId, string StuNo, string CourseNo, string CheckStatus = null)
        {
            AttendanceResult Result = new AttendanceResult();

            try
            {
                SchollTime schollTime  = CourseService.GetSchollTime();
                DateTime   currentTime = schollTime.CurrentTime;

                Z_Student student = StudentService.GetEntity(u => u.F_StuNo == StuNo).FirstOrDefault();

                Z_Class cClass = ClassService.GetEntity(u => u.F_Id == student.Z_C_F_Id).FirstOrDefault();

                //学生今日的课程
                var courses = CourseService.GetStudentCourse(StuNo);
                courses = CourseService.SelectCourseInTheCurrentWeek(courses, schollTime);
                var course = courses.FirstOrDefault(u => u.Week == schollTime.Week && u.EnCode == CourseNo);

                if (course == null) //学生今日没有该课
                {
                    Result.ResultCode = ResultCode.Error;
                    Result.Message    = "今日没该课程,签到失败";
                }
                else
                {
                    var attendance = GetEntity(u => u.F_ID == AttendanceId).FirstOrDefault();
                    if (attendance == null)
                    {
                        Result.ResultCode = ResultCode.Error;
                        Result.Message    = "签到失败,该教师未发起签到";
                        return(Result);
                    }
                    if (course.EnCode != attendance.F_CourseNo)
                    {
                        Result.ResultCode = ResultCode.Error;
                        Result.Message    = "签到失败,与发起ID不匹配";
                        return(Result);
                    }
                    //获取该课程的节次时间
                    List <Z_SectionTime> list        = CourseService.GetSectionTime();
                    Z_SectionTime        sectionTime = list.FirstOrDefault(t => t.F_CourseTimeType.Contains(course.CourseTimeType));

                    DateTime sectionDateTime = DateTime.Parse(sectionTime?.F_Time);
                    //判断该学生是否已经签到过
                    var attend = AttendanceDetailsService
                                 .GetEntity(a => a.Z_A_F_ID == AttendanceId).FirstOrDefault(u => u.F_StuNo == StuNo);
                    if (attend != null && "未进行签到" != attend.F_Result) //已经签到过,不能再进行签到
                    {
                        if (!string.IsNullOrEmpty(CheckStatus))       //教师给学生进行改变签到状态
                        {
                            attend.F_Result = CheckStatus;
                            AttendanceDetailsService.UpdateEntityInfo(attend);
                            Result.ResultCode = ResultCode.Ok;
                            Result.Message    = "修改签到信息成功";
                            return(Result);
                        }
                        Result.ResultCode = ResultCode.Error;
                        Result.Message    = "签到失败,该节课已经签到";
                        return(Result);
                    }

                    //上课前10分钟可以发起签到
                    TimeSpan time = sectionDateTime - currentTime;
                    //attendanceDetails.F_ID = Guid.NewGuid().ToString();
                    //attendanceDetails.Z_A_F_ID = AttendanceId;
                    //attendanceDetails.F_StuName = student?.F_StuName;
                    //attendanceDetails.F_StuNo = StuNo;
                    attend.F_AttenTime = currentTime;
                    //attendanceDetails.F_ClassNo = cClass?.F_ClassNo;
                    Result.Message    = "签到成功";
                    Result.RoomNo     = course.RoomNo;
                    Result.ResultCode = ResultCode.Ok;
                    if (time.Minutes >= 0) //上课前
                    {
                        attend.F_Result = "正常签到";
                    }
                    else if (time.Minutes < 0) //迟到
                    {
                        attend.F_Result = time.Minutes < -120 ? "旷课" : "迟到";
                    }
                    AttendanceDetailsService.UpdateEntityInfo(attend);
                }
            }
            catch (Exception ex)
            {
                Result.ResultCode = ResultCode.Error;
                Result.Error      = ex;
            }
            return(Result);
        }
Beispiel #20
0
        void UpLoadAttendanceResults()
        {
            string cookieName  = string.Empty;
            string cookieValue = string.Empty;
            var    user        = Common.GetCurrentUser();

            var login = new RestClient(Settings.URLs.Host);

            //login.Authenticator = new SimpleAuthenticator("identifier", "*****@*****.**", "password", "q1234567");
            login.Authenticator   = new SimpleAuthenticator(@"identifier", user.username, @"password", user.password);
            login.CookieContainer = new CookieContainer();

            var  request  = new RestRequest(@"auth/local", Method.POST);
            var  response = login.Execute <User>(request);
            User userRes  = response.Data;

            if (userRes == null)
            {
                RunOnUiThread(() => progressDialog.SetMessage(@"Не удалось пройти аутентификацию!"));
            }

            cookieName  = response.Cookies[0].Name;
            cookieValue = response.Cookies[0].Value;

            var queueToUpload = (List <SyncQueue>)SyncQueueManager.GetSyncQueue(selectedDate);

            foreach (var q in queueToUpload)
            {
                try {
                    if ((q.type == SyncQueueType.sqtAttendanceResult) && (!q.isSync))
                    {
                        var client = new RestClient(Settings.URLs.Host);

                        //Debug.WriteLine(@"Получение информации о себе.", @"Info");
                        AttendanceResult attendanceResult = SyncQueueManager.GetAttendaceResult(q.fileLocation);
                        //Attendance attendance = AttendanceManager.GetAttendance (attendanceResult.attendance);
                        RunOnUiThread(() => progressDialog.SetMessage(string.Format(@"Загрузка значения с id {0} по посещению с id:{1}", attendanceResult.id, attendanceResult.attendance)));
                        request = new RestRequest(@"AttendanceResult/", Method.POST);
                        request.AddCookie(cookieName, cookieValue);
                        request.RequestFormat = DataFormat.Json;
                        request.JsonSerializer.ContentType = @"application/json; charset=utf-8";
                        request.AddParameter(@"application/json; charset=utf-8", attendanceResult.ToJSON(), ParameterType.RequestBody);
                        //					attendanceResult.id = 0;
                        //					request.AddBody(attendanceResult);

                        var respAttendanceResult = client.Execute(request);

                        switch (respAttendanceResult.StatusCode)
                        {
                        case HttpStatusCode.OK:
                        case HttpStatusCode.Created:
                            q.isSync = true;
                            SyncQueueManager.SaveSyncQueue(q, false);
                            //						Thread.Sleep (500);
                            RunOnUiThread(() => {
                                progressDialog.SetMessage(string.Format(@"Значение с id {0} по посещению с id:{1} ЗАГРУЖЕНО!", attendanceResult.id, attendanceResult.attendance));
                                //							RefreshContent();
                            });
                            continue;

                        default:
                            //						Thread.Sleep (500);
                            RunOnUiThread(() => progressDialog.SetMessage(@"Не удалось загрузить значение по посещению!"));
                            //						Thread.Sleep (1500);
                            continue;
                        }
                    }
                } catch (Exception ex) {
                    RunOnUiThread(() => progressDialog.SetMessage(@"Error : " + ex.Message));
                    //						Thread.Sleep (1500);
                    continue;
                }
            }
        }
Beispiel #21
0
        /// <summary>
        /// 发起签到
        /// </summary>
        /// <param name="TeacherNum">教工编号</param>
        /// <returns></returns>
        public AttendanceResult InitiatedAttendance(string TeacherNum, string CourseNo)
        {
            var user = UserService.GetEntity(u => u.F_Account == TeacherNum || u.F_RealName == TeacherNum).FirstOrDefault();

            if (user == null)
            {
                return(null);
            }
            Z_Attendance     attendance = new Z_Attendance();
            AttendanceResult Result     = new AttendanceResult();

            try
            {
                //获取今天与开学的时间状态信息
                SchollTime schollTime = CourseService.GetSchollTime();
                //获取该老师的课程
                List <Course> courses = CourseService.GetTeacherCourse(user.F_Account);

                if (courses == null) //今天没课,不能发起签到
                {
                    Result.ResultCode = ResultCode.Error;
                    Result.Message    = "今日没课,发起签到失败";
                    return(Result);
                }
                courses = CourseService.SelectCourseInTheCurrentWeek(courses, schollTime);
                //获取该老师今天的课程
                Course course = courses.Where(u => u.Week == schollTime.Week).FirstOrDefault(u => u.EnCode == CourseNo);

                if (course == null)
                {
                    Result.ResultCode = ResultCode.Error;
                    Result.Message    = "今日没课,发起签到失败";
                    return(Result);
                }
                else //今天有课
                {
                    // 通过今天日期和课程ID来确定考勤ID
                    attendance.F_ID = $"{schollTime.CurrentTime:yyyyMMdd}.{course.Id}";
                    //判断今天是否已经发起签到了
                    var a = GetEntity(u => u.F_ID == attendance.F_ID).FirstOrDefault();
                    if (a != null)
                    {
                        Result.ResultCode = ResultCode.Error;
                        Result.Message    = "发起签到失败,该节课已经发起签到了";
                        return(Result);
                    }
                    //获取该课程的节次时间
                    List <Z_SectionTime> list            = CourseService.GetSectionTime();
                    Z_SectionTime        sectionTime     = list.FirstOrDefault(t => t.F_CourseTimeType.Contains(course.CourseTimeType));
                    DateTime             sectionDateTime = DateTime.Parse(sectionTime?.F_Time);
                    if (sectionDateTime > schollTime.CurrentTime) //上课前
                    {
                        //上课前10分钟可以发起签到
                        TimeSpan time = sectionDateTime - schollTime.CurrentTime;
                        if (time.Minutes <= 10)
                        {
                            attendance.F_TNum          = user.F_Account;
                            attendance.F_CourseNo      = course.EnCode;
                            attendance.F_Flag          = true;
                            attendance.F_ClassRoomNo   = course.RoomNo;
                            attendance.F_ClassNo       = course.Major + course.Classes;
                            attendance.F_InitiatedTime = schollTime.CurrentTime;
                            AddEntity(attendance);
                            // 添加该课程的学生的签到初始化情况到签到详情表
                            #region 添加该课程的学生的签到初始化情况到签到详情表
                            // 获取该课程下的所有学生
                            var studends = CourseService.GetStudentsByCourseId(course);
                            List <Z_AttendanceDetails> attendDetails = new List <Z_AttendanceDetails>();
                            foreach (var stu in studends)
                            {
                                Z_AttendanceDetails attendanceDetails = new Z_AttendanceDetails();
                                attendanceDetails.F_ID        = Guid.NewGuid().ToString("N");
                                attendanceDetails.Z_A_F_ID    = attendance.F_ID;
                                attendanceDetails.F_StuName   = stu?.F_StuName;
                                attendanceDetails.F_StuNo     = stu.F_StuNo;
                                attendanceDetails.F_Flag      = true;
                                attendanceDetails.F_AttenTime = schollTime.CurrentTime;
                                attendanceDetails.F_Result    = "未进行签到";
                                attendanceDetails.F_ClassNo   = stu.Z_Class.F_ClassNo;
                                attendDetails.Add(attendanceDetails);
                            }
                            AttendanceDetailsService.AddEntitys(attendDetails);
                            #endregion
                            Result.RoomNo       = course.RoomNo;
                            Result.ResultCode   = ResultCode.Ok;
                            Result.Message      = "发起签到成功";
                            Result.AttendanceId = attendance.F_ID;
                        }
                    }
                    else //上课后
                    {
                        Result.ResultCode = ResultCode.Error;
                        Result.Message    = "已经上课,不能发起签到";
                    }
                }
            }
            catch (Exception exception)
            {
                Result.ResultCode = ResultCode.Error;
                Result.Message    = "发起签到失败";
                Result.Error      = exception;
                ExceptionHelper.AddException(exception);
                return(Result);
            }
            return(Result);
        }
Beispiel #22
0
        void RefreshContent()
        {
            llSyncItems.RemoveAllViews();
            queue = (List <SyncQueue>)SyncQueueManager.GetSyncQueue(selectedDate);
            foreach (var q in queue)
            {
                View view = LayoutInflater.Inflate(Resource.Layout.SyncFragmentItem, null);

                RelativeLayout rl = view.FindViewById <RelativeLayout> (Resource.Id.sfiRelativeLayout);
                ImageView      iv = view.FindViewById <ImageView> (Resource.Id.sfiStatusImage);

                TextView type = view.FindViewById <TextView> (Resource.Id.sfiTypeInfoText);
                TextView loc  = view.FindViewById <TextView> (Resource.Id.sfiLocationText);

                try {
                    if (q.isSync)
                    {
                        rl.SetBackgroundColor(Android.Graphics.Color.LightGreen);
                        iv.SetImageResource(Resource.Drawable.ic_check_circle_white_36dp);
                        type.SetTextAppearance(this, Resource.Style.text_success);
                        loc.SetTextAppearance(this, Resource.Style.text_success_small);
                    }
                    else
                    {
                        rl.SetBackgroundColor(Android.Graphics.Color.LightPink);
                        iv.SetImageResource(Resource.Drawable.ic_highlight_off_white_36dp);
                        type.SetTextAppearance(this, Resource.Style.text_danger);
                        loc.SetTextAppearance(this, Resource.Style.text_danger_small);
                    }

                    Attendance att   = null;
                    Pharmacy   pharm = null;
                    switch (q.type)
                    {
                    case SyncQueueType.sqtAttendance:
                        att       = AttendanceManager.GetAttendance(q.itemID);
                        pharm     = PharmacyManager.GetPharmacy(att.pharmacy);
                        type.Text = string.Format(@"Тип: Посещение аптеки {0} за дату {1}", pharm.fullName, att.date.ToString(@"d"));
                        loc.Text  = string.Format(@"Размещение: {0}", q.fileLocation);
                        break;

                    case SyncQueueType.sqtAttendanceResult:
                        AttendanceResult attRes = AttendanceResultManager.GetAttendanceResult(q.itemID);
                        att       = AttendanceManager.GetAttendance(attRes.attendance);
                        pharm     = PharmacyManager.GetPharmacy(att.pharmacy);
                        type.Text = string.Format(@"Тип: Значение по препарату в посещение аптеки {0} за дату {1}", pharm.fullName, att.date.ToString(@"d"));
                        loc.Text  = string.Format(@"Размещение: {0}", q.fileLocation);
                        break;

                    case SyncQueueType.sqtAttendanceGPSPoint:
                        AttendanceGPSPoint attGPS = AttendanceGPSPointManager.GetAttendanceGPSPoint(q.itemID);
                        att       = AttendanceManager.GetAttendance(attGPS.attendance);
                        pharm     = PharmacyManager.GetPharmacy(att.pharmacy);
                        type.Text = string.Format(@"Тип: GPS значение в посещение аптеки {0} за дату {1} - lat:{2}, lon:{3}", pharm.fullName, att.date.ToString(@"d"), attGPS.latitude, attGPS.longitude);
                        loc.Text  = string.Format(@"Размещение: {0}", q.fileLocation);
                        break;

                    case SyncQueueType.sqtAttendancePhoto:
                        AttendancePhoto attPho = AttendancePhotoManager.GetAttendancePhoto(q.itemID);
                        type.Text = string.Format(@"Фото: {0}", attPho.photoPath);
                        loc.Text  = q.fileLocation;
                        break;

                    default:
                        type.Text = @"Неизвестный тип файла";
                        type.SetTextColor(Android.Graphics.Color.DarkRed);
                        break;
                    }
                } catch (Exception ex) {
                    type.Text = @"Error:";
                    loc.Text  = ex.Message;
                }

                llSyncItems.AddView(view);
            }
        }