コード例 #1
0
        public JsonResult LoadTask(string taskID)
        {
            TaskBLL   bll = new TaskBLL();
            DairyTask v;

            v = bll.GetTaskByID(Int32.Parse(taskID));
            string displayEarNum = CowBLL.ConvertEarNumToDisplayEarNum(v.EarNum);

            GroupingRecordBLL grbBLL   = new GroupingRecordBLL();
            GroupingRecord    gr       = grbBLL.GetGroupingRecordByTaskID(Int32.Parse(taskID));
            CowGroupBLL       cgBLL    = new CowGroupBLL();
            HouseBLL          hBLL     = new HouseBLL();
            CowGroup          oldgroup = cgBLL.GetCowGroupInfo(gr.OriginalGroupID);
            CowGroup          newgroup = cgBLL.GetCowGroupInfo(gr.TargetGroupID);
            House             oldhouse = hBLL.GetHouseByID(UserBLL.Instance.CurrentUser.Pasture.ID, gr.OriginalHouseID);
            House             newhouse = hBLL.GetHouseByID(UserBLL.Instance.CurrentUser.Pasture.ID, gr.TargetHouseID);

            return(Json(new
            {
                EarNum = v.EarNum,
                DisplayEarNum = displayEarNum,
                ArrivalTime = v.ArrivalTime.ToString("yyyy-MM-dd"),
                Operator = v.OperatorID,
                OldGroup = oldgroup.Name,
                OldHouse = oldhouse.Name,
                NewGroup = newgroup.Name,
                NewHouse = newhouse.Name
            }, JsonRequestBehavior.AllowGet));
        }
コード例 #2
0
        /// <summary>
        /// 插入转群任务
        /// </summary>
        /// <returns></returns>
        public JsonResult InsertChangeGroupTask()
        {
            bool    bResult    = false;
            int     earNum     = CowBLL.ConvertDislayEarNumToEarNum(Request["DisplayEarNum"].ToString(), UserBLL.Instance.CurrentUser.Pasture.ID);
            int     pastureID  = UserBLL.Instance.CurrentUser.Pasture.ID;
            TaskBLL bllTask    = new TaskBLL();
            int     operatorID = bllTask.AssignTask(pastureID, earNum, Role.FARM_FEEDER_ID);

            if (earNum != 0)
            {
                DairyTask t = new DairyTask
                {
                    EarNum      = earNum,
                    TaskType    = TaskType.GroupingTask,
                    Status      = DairyTaskStatus.Initial,
                    PastureID   = pastureID,
                    OperatorID  = operatorID,
                    ArrivalTime = DateTime.Now, //转群当天要做
                    InputTime   = DateTime.Now,
                    DeadLine    = DateTime.Now.AddDays(15)
                };

                bResult = bllTask.AddTask(t);

                GroupingRecord gRecord = new GroupingRecord
                {
                    TaskID          = t.ID,
                    EarNum          = t.EarNum,
                    TargetGroupID   = Convert.ToInt32(Request["TargetGroupID"]),
                    TargetHouseID   = Convert.ToInt32(Request["TargetHouseID"]),
                    OriginalGroupID = Convert.ToInt32(Request["OriginalGroupID"]),
                    OriginalHouseID = Convert.ToInt32(Request["OriginalHouseID"])
                };

                GroupingRecordBLL bllGroupingRecord = new GroupingRecordBLL();
                bllGroupingRecord.InsertGroupingRecord(gRecord);
            }

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