コード例 #1
0
        public DNTimeJobItem JobTimeCheckOut(List <CheckInItem> list, DNTimeJobItem objItem, decimal totalS)
        {
            var obj = list.FirstOrDefault(m => (m.Hms >= totalS && m.Hme > totalS) || m.Hme + 32 > totalS);

            if (obj != null)
            {
                var b = obj.Hme - totalS;
                objItem.ScheduleEndID = obj.ID;
                objItem.MinutesEarly  = b > 0 ? (int)b : 0;
            }
            return(objItem);
        }
コード例 #2
0
        public DNTimeJobItem JobTimeCheckIn(List <CheckInItem> list, DNTimeJobItem objItem, decimal totalS)
        {
            var obj = list.FirstOrDefault(m => (m.Hms <totalS && m.Hme> totalS) || m.Hms - 32 <= totalS);

            if (obj != null)
            {
                var b = totalS - obj.Hms;
                objItem.ScheduleID   = obj.ID;
                objItem.MinutesLater = b > 0 ? (int)b : 0;
            }
            return(objItem);
        }
コード例 #3
0
 public DN_Time_Job UpdateBase(DN_Time_Job timeJob, DNTimeJobItem timeJobItem)
 {
     timeJob.DateCreated   = timeJobItem.DateCreated;
     timeJob.DateEnd       = timeJobItem.DateEnd;
     timeJob.UserId        = timeJobItem.UserId;
     timeJob.AgencyID      = timeJobItem.AgencyID;
     timeJob.ScheduleID    = timeJobItem.ScheduleID;
     timeJob.ScheduleEndID = timeJobItem.ScheduleEndID;
     timeJob.MinutesLater  = timeJobItem.MinutesLater;
     timeJob.MinutesEarly  = timeJobItem.MinutesEarly;
     return(timeJob);
 }
コード例 #4
0
        public ActionResult AjaxForm()
        {
            var dnTimeJob = new DNTimeJobItem();

            if (DoAction == ActionType.Edit)
            {
                dnTimeJob = _dnTimeJobApi.GetItemById(UserItem.AgencyID, ArrId.FirstOrDefault());
            }
            ViewBag.UserId     = _userApi.GetAll(UserItem.AgencyID);
            ViewData.Model     = dnTimeJob;
            ViewBag.Action     = DoAction;
            ViewBag.ActionText = ActionText;
            return(View());
        }
コード例 #5
0
        public DNTimeJobItem JobTimeCheckOut(Guid userId, DNTimeJobItem objItem)
        {
            var date   = DateTime.Now;
            var totalS = date.Hour * 3600 + date.Minute * 60;
            var list   = GetWeeklyScheduleday(userId, DateTime.Today).OrderByDescending(m => m.ScheduleTimeStart);
            var obj    = list.FirstOrDefault(m => (m.ScheduleTimeStart >= totalS && m.ScheduleTimeEnd > totalS) || m.ScheduleTimeEnd <= totalS);

            objItem.DateEnd = ConvertDate.TotalSeconds(date);
            if (obj != null)
            {
                objItem.ScheduleEndID = obj.ScheduleID;
                objItem.MinutesEarly  = (int)(obj.ScheduleTimeEnd - totalS) / 60;
            }
            objItem.UserId = userId;
            return(objItem);
        }
コード例 #6
0
        public DNTimeJobItem JobTimeCheckIn(Guid userId, DNTimeJobItem objItem)
        {
            var date   = DateTime.Now;
            var totalS = date.Hour * 3600 + date.Minute * 60;
            var list   = GetWeeklyScheduleday(userId, DateTime.Today);
            var obj    = list.FirstOrDefault(m => m.ScheduleTimeStart >= totalS || (m.ScheduleTimeStart <totalS && m.ScheduleTimeEnd> totalS));

            objItem.DateCreated = ConvertDate.TotalSeconds(date);
            if (obj != null)
            {
                objItem.ScheduleID   = obj.ScheduleID;
                objItem.MinutesLater = (int)(obj.ScheduleTimeStart - totalS) / 60;
            }
            objItem.UserId = userId;
            return(objItem);
        }
コード例 #7
0
        public ActionResult CheckIn(string key, string codeon, int agencyid)
        {
            if (key == "checkinfdi")
            {
                var userid = _dnUser.GetUserIdByCodeCheckIn(codeon, agencyid);
                if (userid != null && userid.UserId != new Guid())
                {
                    UpdateStack(codeon, agencyid, userid.IsService);

                    var date      = DateTime.Now;
                    var totalS    = date.Hour * 60 + date.Minute;
                    var dates     = date.TotalSeconds();
                    var dnTimeJob = new DNTimeJobItem
                    {
                        UserId        = userid.UserId,
                        AgencyID      = agencyid,
                        DateCreated   = dates,
                        DateEnd       = dates,
                        ScheduleEndID = null,
                        MinutesEarly  = 0,
                        ScheduleID    = null,
                        MinutesLater  = 0,
                    };
                    var list = _calendarApi.GetItemByUserIdDate(userid.UserId, agencyid, dates).OrderByDescending(m => m.Hms).ToList();
                    if (list.Any())
                    {
                        //// Get Ca check in chấm công
                        dnTimeJob = JobTimeCheckIn(list, dnTimeJob, totalS);
                        //// Get Ca check out chấm công
                        dnTimeJob = JobTimeCheckOut(list, dnTimeJob, totalS);
                    }
                    var json = new JavaScriptSerializer().Serialize(dnTimeJob);
                    var obj  = _dnTimeJobApi.Add("", json, agencyid);
                    return(Json(1, JsonRequestBehavior.AllowGet));
                }
            }
            return(Json(0, JsonRequestBehavior.AllowGet));
        }
コード例 #8
0
        public ActionResult Actions()
        {
            var msg       = new JsonMessage();
            var dnTimeJob = new DNTimeJobItem();
            List <DNTimeJobItem> ltsDNTimeJob;
            //var dateCreated = Request["_DateCreated"];
            //var dateEnd = Request["_DateEnd"];
            var json  = "";
            var lstId = Request["itemId"];

            switch (DoAction)
            {
            case ActionType.Add:
                try
                {
                    UpdateModel(dnTimeJob);
                    // check in chấm công
                    //var inJob = JobTimeCheckIn(UserId, dnTimeJob);
                    //if (inJob != null)
                    //{
                    //    dnTimeJob.ScheduleID = inJob.ScheduleID;
                    //    dnTimeJob.ScheduleEndID = null;
                    //    dnTimeJob.DateCreated = ConvertDate.TotalSeconds(DateTime.Now);
                    //}
                    ////// check out chấm công
                    //var outJob = JobTimeCheckOut(UserId, dnTimeJob);
                    //if (outJob != null)
                    //{
                    //    dnTimeJob.DateEnd = outJob.DateEnd;
                    //    dnTimeJob.ScheduleEndID = outJob.ScheduleEndID;
                    //}

                    json = new JavaScriptSerializer().Serialize(dnTimeJob);
                    if (Convert.ToInt32(ArrId.FirstOrDefault()) > 0)
                    {
                        _dnTimeJobApi.Update(UserItem.AgencyID, json, ArrId.FirstOrDefault());
                    }
                    else
                    {
                        _dnTimeJobApi.Add(CodeLogin(), json, UserItem.AgencyID);
                    }

                    msg = new JsonMessage
                    {
                        Erros   = false,
                        ID      = dnTimeJob.ID.ToString(),
                        Message = string.Format("Cập nhật: <b>{0}</b>", Server.HtmlEncode(dnTimeJob.UserId.ToString()))
                    };
                }
                catch (Exception ex)
                {
                    LogHelper.Instance.LogError(GetType(), ex);
                }
                break;

            case ActionType.Edit:
                try
                {
                    UpdateModel(dnTimeJob);
                    dnTimeJob.DateCreated = ConvertDate.TotalSeconds(DateTime.Now);
                    dnTimeJob.DateEnd     = ConvertDate.TotalSeconds(DateTime.Now);
                    json = new JavaScriptSerializer().Serialize(dnTimeJob);
                    _dnTimeJobApi.Update(UserItem.AgencyID, json, ArrId.FirstOrDefault());

                    msg = new JsonMessage
                    {
                        Erros   = false,
                        ID      = dnTimeJob.ID.ToString(),
                        Message = string.Format("Đã cập nhật : <b>{0}</b>", Server.HtmlEncode(dnTimeJob.UserId.ToString()))
                    };
                }
                catch (Exception ex)
                {
                    LogHelper.Instance.LogError(GetType(), ex);
                }
                break;

            case ActionType.Delete:
                ltsDNTimeJob = _dnTimeJobApi.GetListByArrId(UserItem.AgencyID, lstId);
                foreach (var item in ltsDNTimeJob)
                {
                    UpdateModel(item);
                    json = new JavaScriptSerializer().Serialize(item);
                    _dnTimeJobApi.Update(UserItem.AgencyID, json, item.ID);
                }
                msg = new JsonMessage
                {
                    Erros   = false,
                    ID      = dnTimeJob.ID.ToString(),
                    Message = string.Format("Đã cập nhật : <b>{0}</b>", Server.HtmlEncode(string.Join(", ", ltsDNTimeJob.Select(c => c.UserId))))
                };
                break;
            }

            if (string.IsNullOrEmpty(msg.Message))
            {
                msg.Message = "Không có hành động nào được thực hiện.";
                msg.Erros   = true;
            }

            return(Json(msg, JsonRequestBehavior.AllowGet));
        }