/********************************************************
        * 获取用户签到状态
        * date:查询日期 可以为null
        * rate:出勤率,全勤1,非全勤0,所有null
        * ******************************************************/
        private void GetSignStatus(HttpContext context)
        {
            //登录账号的ID
            string empID = UsrAuth.GetempID(context.Session);
            FeedBackMsg <CheckInInfo> feedBackMsg = new FeedBackMsg <CheckInInfo>();
            //获取当前的考勤信息
            CheckInInfo checkInInfo = CheckInInfoService.Instance.GetCurrentCheckInInfo(int.Parse(empID));

            if (checkInInfo != null)
            {
                //已经签过到
                feedBackMsg.Code = 1;
                feedBackMsg.Msg  = "已经签到";
                feedBackMsg.Obj  = checkInInfo;
            }
            else
            {
                //还没有签到
                feedBackMsg.Code = 1;
                feedBackMsg.Msg  = "还没签到";
                feedBackMsg.Obj  = null;
            }
            string json = ObjToJson.ToJson(feedBackMsg);

            context.Response.Write(json);
        }
        public ActionResult Index(int projectId, int userId, CheckInInfo checkInInfo)
        {
            Checkin checkin = CheckInHelper.SaveCheckIn(projectId, userId, checkInInfo);

            EmailHelper.SendEmail(checkin);

            return(Json(new CheckInResponse("Checkin recorded, email sent")));
        }
        private string makeUpdateSql(CheckInInfo checkInInfo, int normalCount, int lateCoutn, int absentCount, int leaveEarlyCount)
        {
            string sql = string.Format(@"SET F_ASRealityDuration=F_ASRealityDuration+({0}),
                                        F_ASNormalNumber=F_ASNormalNumber+({1}),F_ASLeaveEavlyNumber=F_ASLeaveEavlyNumber+({2}),
                                        F_ASLateNumber=F_ASLateNumber+({3}),F_ASAbsenteeismNumber=F_ASAbsenteeismNumber+({4}) WHERE F_EmpID={5}",
                                       checkInInfo.CIRealityWorkDuration, normalCount, leaveEarlyCount, lateCoutn, absentCount, checkInInfo.EmpID);

            return(sql);
        }
        private void GetInfo(HttpContext context)
        {
            int selectedCheckInInfoID = int.Parse(context.Request["id"]);

            CheckInInfo checkInInfo = CheckInInfoService.Instance.GetCheckInInfo(selectedCheckInInfoID);

            FeedBackMsg <CheckInInfo> feedBack = new FeedBackMsg <CheckInInfo>()
            {
                Code = 1,
                Msg  = "选中的签到项的具体信息",
                Obj  = checkInInfo
            };
            string json = ObjToJson.ToJson(feedBack);

            context.Response.Write(json);
        }
Esempio n. 5
0
        internal static Checkin SaveCheckIn(int projectId, int userId, CheckInInfo checkInInfo)
        {
            var context = new trackgitentitycontext();

            var checkIn = new Checkin
            {
                Project = context.Projects.First(p => p.Id == projectId),
                User    = context.Users.First(u => u.Id == userId),
                Comment = checkInInfo.Comment
            };

            context.AddToCheckins(checkIn);

            context.SaveChanges();

            return(checkIn);
        }
        private static List <CheckInInfo> getCheckInInfo(DataRowCollection rows)
        {
            if (rows == null || rows.Count <= 0)
            {
                return(null);
            }
            int iRowLength          = rows.Count;
            List <CheckInInfo> list = new List <CheckInInfo>();

            for (int i = 0; i < iRowLength; i++)
            {
                CheckInInfo checkInInfo = new CheckInInfo()
                {
                    CIID                    = DataBase.ObjectToInt(rows[i]["F_CIID"]),
                    EmpID                   = DataBase.ObjectToInt(rows[i]["F_EmpID"]),
                    EmpName                 = DataBase.ObjectToString(rows[i]["F_EmpName"]),
                    DepID                   = DataBase.ObjectToInt(rows[i]["F_DepID"]),
                    DepName                 = DataBase.ObjectToString(rows[i]["F_DepName"]),
                    CISignInDate            = DataBase.ObjectToDate(rows[i]["F_CISignInDate"].ToString()),
                    CISignOutDate           = DataBase.ObjectToDate(rows[i]["F_CISignOutDate"].ToString()),
                    CIRealityWorkDuration   = DataBase.ObjectToInt(rows[i]["F_CIRealityWorkDuration"]),
                    AppendSignInPersonID    = DataBase.ObjectToInt(rows[i]["F_AppendSignInPersonID"]),
                    AppendSignInPersonName  = DataBase.ObjectToString(rows[i]["F_AppendSignInPersonName"]),
                    AppendSignInNote        = DataBase.ObjectToString(rows[i]["F_AppendSignInPersonNote"]),
                    AppendSignOutPersonID   = DataBase.ObjectToInt(rows[i]["F_AppendSignOutPersonID"]),
                    AppendSignOutPersonName = DataBase.ObjectToString(rows[i]["F_AppendSignOutPersonName"]),
                    AppendSignOutPersonNote = DataBase.ObjectToString(rows[i]["F_AppendSignOutPersonNote"]),
                    CIIsLate                = DataBase.ObjectToBool(rows[i]["F_CIIsLate"]),
                    CIIsLeaveEavly          = DataBase.ObjectToBool(rows[i]["F_CIIsLeaveEarvly"]),
                    CIIsAbsenteeism         = DataBase.ObjectToBool(rows[i]["F_CIIsAbsenteeism"]),
                    IsSignIn                = DataBase.ObjectToBool(rows[i]["F_CIIsSignIn"]),
                    IsSignOut               = DataBase.ObjectToBool(rows[i]["F_CIIsSignOut"]),
                    ISCalculate             = DataBase.ObjectToBool(rows[i]["F_CIIsCalculate"]),
                    CIIsNormal              = DataBase.ObjectToBool(rows[i]["F_CIIsNormal"]),
                    CICreateDate            = rows[i]["F_CICreateDate"].ToString(),
                    Date                    = DataBase.ObjectToString(rows[i]["F_Date"])
                };
                list.Add(checkInInfo);
            }
            return(list);
        }
Esempio n. 7
0
        public void CheckIn(CheckInInfo chkInfo, Action <Exception, MonitoringSummary> callback)
        {
            var request = new RestRequest("/api/people/" + chkInfo.Id + "/check_in/", Method.POST);

            request.AddParameter("scope", chkInfo.scope);
            request.AddParameter("status", chkInfo.status.ToLower());
            _client.ExecuteAsync <MonitoringSummary>(request, (res) =>
            {
                if (res.StatusCode == System.Net.HttpStatusCode.OK)
                {
                    callback(null, res.Data);
                    return;
                }
                else
                {
                    var msg = string.Format("{0}\n{1}\n{2}",
                                            res.ErrorMessage, res.Content, res.StatusDescription);
                    callback(new Exception(msg), null);
                    return;
                }
            });
        }
        private string makeInsertSql(CheckInInfo checkInInfo, WorkDuration workDuration, int asMonth)
        {
            string sql = "";
            int    normal = 0, late = 0, leaveEarly = 0, absent = 0;

            if (checkInInfo.CIIsNormal)//正常
            {
                normal = 1;
            }
            if (checkInInfo.CIIsAbsenteeism)//缺席
            {
                absent = 1;
            }
            if (checkInInfo.CIIsLate)//迟到
            {
                late = 1;
            }
            if (checkInInfo.CIIsLeaveEavly)//早退
            {
                leaveEarly = 1;
            }
            sql = string.Format(@"VALUES({0},'{1}',{2},'{3}',{4},{5},{6},{7},{8},{9},{10},'{11}');",
                                checkInInfo.EmpID,
                                checkInInfo.EmpName,
                                checkInInfo.DepID,
                                checkInInfo.DepName,
                                asMonth,
                                workDuration.WDMonthDuration * workDuration.WDDayDuration,
                                checkInInfo.CIRealityWorkDuration,
                                late,                                      //迟到次数
                                leaveEarly,                                //早退次数
                                absent,                                    //缺席次数
                                normal,                                    //正常次数
                                DateTime.Now.ToString("yyyy-MM-dd"));

            return(sql);
        }
        /// **************************************************************
        /// <summary>
        /// 描述:为所有人补签到签退
        /// </summary>
        /// <param name="date">签到或者签退的日期</param>
        /// <param name="signInTime">签到时间</param>
        /// <param name="signOutTime">签退时间</param>
        /// <param name="appendForEmpID">被补签到人的ID</param>
        /// <param name="note">说明</param>
        /// <returns></returns>
        /// **************************************************************
        public int UpdateCheckInInfoBySystem(string date, string signInTime, string signOutTime, string note, int appendEmpID, string appendEmpName, int appendForEmpID)
        {
            string             sql             = "";
            DateTime           signInDate      = DateTime.Parse(date + " " + signInTime);
            DateTime           signOutDate     = DateTime.Parse(date + " " + signOutTime);
            TimeSpan           timeSpan        = signOutDate - signInDate;
            WorkDuration       workDuration    = WorkDurationService.Instance.GetWorkDuration();
            List <CheckInInfo> modifyedEmpList = new List <CheckInInfo>();
            int workTime = timeSpan.Hours;

            if (workTime > workDuration.WDDayDuration)
            {
                workTime = workDuration.WDDayDuration;
            }
            if (appendForEmpID == 0)
            {
                List <EmployeeInfo> empList = EmployeeService.Instance.GetList();

                if (empList != null && empList.Count > 0)
                {
                    for (int i = 0; i < empList.Count; i++)
                    {
                        //为所有人进行签到签退
                        //判断是否已经签过到/退
                        //MODIFY
                        CheckInInfo checkInfo = isCheckInInfoExisted(date, int.Parse(empList[i].EmpID));
                        if (checkInfo != null)
                        {
                            return(0);
                        }
                        #region ------------------1. 插入语句
                        //MODIFY
                        //SQL语句过长问题
                        sql = string.Format(@"Insert into T_CheckingInInfo(
                                                                F_EmpID,
                                                                F_EmpName,
                                                                F_DepID,
                                                                F_DepName,
                                                                F_CISignInDate,
                                                                F_CISignOutDate,
                                                                F_CIRealityWorkDuration,
                                                                F_AppendSignInPersonID,
                                                                F_AppendSignInPersonName,
                                                                F_AppendSignInPersonNote,
                                                                F_CIIsLate,
                                                                F_CIIsLeaveEarvly,
                                                                F_CIIsAbsenteeism,
                                                                F_CIIsNormal,
                                                                F_CICreateDate,
                                                                F_CIIsSignIn,
                                                                F_CIIsCalculate,
                                                                F_Date
                                                ) 
                                                values({0},'{1}',{2},'{3}','{4}','{5}',{6},{7},'{8}','{9}',{10}, '{11}',{12},{13},'{14}');",
                                            empList[i].EmpID,
                                            empList[i].EmpName,
                                            empList[i].DepID,
                                            empList[i].DepName,
                                            signInDate,
                                            signOutDate,
                                            workTime,
                                            appendEmpID,
                                            appendEmpName,
                                            note.Replace("'", "''"),
                                            makeSql(signOutDate, signInDate, workDuration),
                                            DateTime.Now.ToString("yyyy-MM-dd"),
                                            "0",
                                            "0",
                                            date);
                        #endregion
                        int res = MrDBAccess.ExecuteNonQuery(sql);
                        if (res == 0)
                        {
                            return(0);
                        }
                        modifyedEmpList.Add(GetCheckInfo(int.Parse(empList[i].EmpID), date));
                    }
                }
            }
            else
            {
                //为某个员工进行签到签退
                #region ---------------------------sql语句
                EmployeeInfo employeeInfo = EmployeeService.Instance.GetEmployee(appendForEmpID);
                CheckInInfo  checkInfo    = isCheckInInfoExisted(date, int.Parse(employeeInfo.EmpID));
                if (checkInfo != null)
                {
                    return(0);
                }
                sql = string.Format(@"INSERT INTO T_CheckingInInfo(F_EmpID,
                                                                F_EmpName,
                                                                F_DepID,
                                                                F_DepName,
                                                                F_CISignInDate,
                                                                F_CISignOutDate,
                                                                F_CIRealityWorkDuration,
                                                                F_AppendSignInPersonID,
                                                                F_AppendSignInPersonName,
                                                                F_AppendSignInPersonNote,
                                                                F_CIIsLate,
                                                                F_CIIsLeaveEarvly,
                                                                F_CIIsAbsenteeism,
                                                                F_CIIsNormal,
                                                                F_CICreateDate,
                                                                F_CIIsSignIn,
                                                                F_CIIsCalculate,
                                                                F_Date) 
                                                                VALUES({0},'{1}',{2},'{3}','{4}','{5}',{6},{7},'{8}','{9}',{10}, '{11}',{12},{13},'{14}')",
                                    employeeInfo.EmpID,
                                    employeeInfo.EmpName,
                                    employeeInfo.DepID,
                                    employeeInfo.DepName,
                                    signInDate,
                                    signOutDate,
                                    workTime,
                                    appendEmpID,
                                    appendEmpName,
                                    note.Replace("'", "''"),
                                    makeSql(signOutDate, signInDate, workDuration),
                                    DateTime.Now.ToString("yyyy-MM-dd"),
                                    "0",
                                    "0",
                                    date);
                #endregion
                int res = MrDBAccess.ExecuteNonQuery(sql);
                if (res == 0)
                {
                    return(0);
                }
                modifyedEmpList.Add(GetCheckInfo(int.Parse(employeeInfo.EmpID), date));
            }
            //List<CheckInInfo> modifyedEmpList = GetCheckInInfoListNoCalculate();
            MonthAttendanceService.Instance.UpdateForAppendSignEmp(modifyedEmpList, true);
            return(1);
        }
        private void doCalculate(CheckInInfo newCheckInfo, CheckInInfo oldCheckInInfo)
        {
            int normalCount = 0, lateCount = 0, absentCount = 0, leaveEarlyCount = 0;

            if (oldCheckInInfo.ISCalculate)
            {
                if (oldCheckInInfo.CIIsNormal != newCheckInfo.CIIsNormal && oldCheckInInfo.CIIsNormal)
                {
                    normalCount = -1;
                }
                if (oldCheckInInfo.CIIsNormal != newCheckInfo.CIIsNormal && newCheckInfo.CIIsNormal)
                {
                    normalCount = 1;
                }
                if (oldCheckInInfo.CIIsLate != newCheckInfo.CIIsLate && oldCheckInInfo.CIIsLate)
                {
                    lateCount = -1;
                }
                if (oldCheckInInfo.CIIsLate != newCheckInfo.CIIsLate && newCheckInfo.CIIsLate)
                {
                    lateCount = 1;
                }
                if (oldCheckInInfo.CIIsLeaveEavly != newCheckInfo.CIIsLeaveEavly && oldCheckInInfo.CIIsLeaveEavly)
                {
                    leaveEarlyCount = -1;
                }
                if (oldCheckInInfo.CIIsLeaveEavly != newCheckInfo.CIIsLeaveEavly && newCheckInfo.CIIsLeaveEavly)
                {
                    leaveEarlyCount = 1;
                }
                if (oldCheckInInfo.CIIsAbsenteeism != newCheckInfo.CIIsAbsenteeism && oldCheckInInfo.CIIsAbsenteeism)
                {
                    absentCount = -1;
                }
                if (oldCheckInInfo.CIIsAbsenteeism != newCheckInfo.CIIsAbsenteeism && newCheckInfo.CIIsAbsenteeism)
                {
                    absentCount = 1;
                }
                int oldWorkTime = oldCheckInInfo.CIRealityWorkDuration;
                int newWorkTime = newCheckInfo.CIRealityWorkDuration;
                if (newWorkTime != oldWorkTime)
                {
                    newCheckInfo.CIRealityWorkDuration = newWorkTime - oldWorkTime;
                }
            }
            else
            {
                if (newCheckInfo.CIIsNormal)
                {
                    normalCount = 1;
                }
                if (newCheckInfo.CIIsLeaveEavly)
                {
                    leaveEarlyCount = 1;
                }
                if (newCheckInfo.CIIsLate)
                {
                    lateCount = 1;
                }
                if (newCheckInfo.CIIsAbsenteeism)
                {
                    absentCount = 1;
                }
            }
            List <CheckInInfo> checkInfoList = new List <CheckInInfo>();

            checkInfoList.Add(newCheckInfo);
            MonthAttendanceService.Instance.UpdateForAppendSignEmp(checkInfoList, false, normalCount, lateCount, absentCount, leaveEarlyCount);
        }
        /*****************************************************************
         * 功能:补签到补签退
         *       补签到
         *       补签退
         * 参数:checkInInfoID      被操作的考勤信息的ID(可选参数)
         *       empID              补签到(补签退)员工ID
         *       empName            补签到(补签退)员工姓名
         *       note               补签到(补签退)说明
         * 返回:成功“1”,失败“0”
         * **************************************************************/
        public int UpdateCheckInInfoBySystem(string empID, string empName, int depID, string depName, string date, string note, string appendEmpID = null, string appendEmpName = null, int checkInInfoID = 0)
        {
            //MODIFY
            string sql = "";

            if (checkInInfoID == 0)
            {
                //补签到
                //1. 如果已经被补签到过,更新操作
                CheckInInfo  oldCheckInfo = isCheckInInfoExisted(DateTime.Parse(date).ToString("yyyy-MM-dd"), int.Parse(empID));
                WorkDuration workDuration = WorkDurationService.Instance.GetWorkDuration();
                if (oldCheckInfo != null)
                {
                    DateTime signInTime  = DateTime.Parse(date);
                    DateTime signOutTime = DateTime.Parse(oldCheckInfo.CISignOutDate);
                    TimeSpan ts          = signOutTime - signInTime;
                    int      workTime    = 0;
                    if (ts.Minutes > 40)
                    {
                        workTime = ts.Hours + 1;
                    }
                    workTime = ts.Hours;
                    if (workTime > workDuration.WDDayDuration)
                    {
                        workTime = workDuration.WDDayDuration;
                    }
                    sql = string.Format(@"UPDATE T_CheckingInInfo SET F_CISignInDate='{0}', F_AppendSignOutPersonID={1}, F_AppendSignOutPersonName='{2}', 
                                                                F_AppendSignOutPersonNote='{3}', F_CIRealityWorkDuration={4} 
                                                                {5} WHERE F_CIID={6}",
                                        date, appendEmpID, appendEmpName, note.Replace("'", "''"), workTime,
                                        makeUpdateSql(signInTime, signOutTime, workDuration, DateTime.Parse(date).ToString("yyyy-MM-dd")), oldCheckInfo.CIID);
                    int res = MrDBAccess.ExecuteNonQuery(sql);
                    if (res == 0)
                    {
                        return(0);
                    }
                    CheckInInfo newCheckInfo = GetCheckInInfo(oldCheckInfo.CIID);
                    doCalculate(newCheckInfo, oldCheckInfo);
                    return(1);
                }
                #region --------------------------------------------插入Sql语句
                else
                {
                    //2. 没有被补签到过,进行插入操作
                    sql = string.Format(@"Insert into T_CheckingInInfo(
                                                                F_EmpID,
                                                                F_EmpName,
                                                                F_DepID,
                                                                F_DepName,
                                                                F_CISignInDate,
                                                                F_CIRealityWorkDuration,
                                                                F_AppendSignInPersonID,
                                                                F_AppendSignInPersonName,
                                                                F_AppendSignInPersonNote,
                                                                F_CIIsLate,
                                                                F_CIIsLeaveEarvly,
                                                                F_CIIsAbsenteeism,
                                                                F_CIIsNormal,
                                                                F_CICreateDate,
                                                                F_CIIsSignIn,
                                                                F_CIIsSignOut,
                                                                F_CIIsCalculate,
                                                                F_Date
                                                ) 
                                                values({0},'{1}',{2},'{3}','{4}',{5},{6},'{7}','{8}',{9},{10},{11},{12},'{13}',{14},{15},{16}, '{17}')",
                                        empID,
                                        empName,
                                        depID,
                                        depName,
                                        date,
                                        0,
                                        int.Parse(appendEmpID),
                                        appendEmpName,
                                        note.Replace("'", "''"),
                                        "0 ",               //F_CIIsLate
                                        "0",                //F_CIIsLeaveEavly
                                        "0",                //F_CIIsAbsenteeism
                                        "0",                //F_CIIsNormal
                                        DateTime.Now.ToString("yyyy-MM-dd"),
                                        "0",
                                        "0",
                                        "0",
                                        DateTime.Parse(date).ToString("yyyy-MM-dd"));                //设置补签为true
                    int res = MrDBAccess.ExecuteNonQuery(sql);
                    if (res == 0)
                    {
                        return(0);
                    }
                    return(1);
                }
                #endregion
            }
            else
            {
                #region ------------------------------------------补签退
                CheckInInfo oldCheckInInfo = GetCheckInInfo(checkInInfoID);
                DateTime    signInTime     = DateTime.Parse(oldCheckInInfo.CISignInDate);
                DateTime    signOutTime    = DateTime.Parse(date);
                //MODIFY 补签退时进行这一天的工作装填统计
                TimeSpan ts       = signOutTime - signInTime;
                int      workTime = 0;
                if (ts.Minutes > 40)
                {
                    workTime = ts.Hours + 1;
                }
                workTime = ts.Hours;

                sql = string.Format(@"UPDATE T_CheckingInInfo SET F_CISignOutDate='{0}', F_AppendSignOutPersonID={1}, F_AppendSignOutPersonName='{2}', 
                                                                F_AppendSignOutPersonNote='{3}', F_CIRealityWorkDuration={4} 
                                                                {5} WHERE F_CIID={6}",
                                    signOutTime, appendEmpID, appendEmpName, note, workTime,
                                    makeUpdateSql(signInTime, signOutTime, WorkDurationService.Instance.GetWorkDuration(), DateTime.Parse(date).ToString("yyyy-MM-dd")), checkInInfoID);
                int res = MrDBAccess.ExecuteNonQuery(sql);
                #endregion

                #region ---------------------------------------补签退后面的统计处理
                //补签退失败
                if (res == 0)
                {
                    return(0);
                }
                else
                {
                    //补签退成功
                    //对被补签的员工进行统计
                    CheckInInfo newCheckInfo = GetCheckInInfo(checkInInfoID);
                    doCalculate(newCheckInfo, oldCheckInInfo);
                    return(1);
                }
                #endregion
            }
        }