Ejemplo n.º 1
0
        public void DispatchRequest(RequestInfo requestInfo, DispatchInfo dispatchInfo, UserInfo user)
        {
            RequestInfo info = GetRequest(requestInfo.ID);

            List <DispatchInfo> dispatchInfos = this.dispatchDao.GetOpenDispatchesByRequestID(requestInfo.ID);
            bool isExisted = dispatchInfos.Count > 0 ? true : false;

            if (info.DistributeDate == DateTime.MinValue)
            {
                this.requestDao.UpdateRequestDistributeDate(requestInfo.ID, dispatchInfo.ScheduleDate);
            }
            if (isExisted == false)
            {
                requestInfo.LastStatus.ID = requestInfo.Status.ID;
            }
            requestInfo.Status.ID = RequestInfo.Statuses.Allocated;
            if (info.Status.ID == RequestInfo.Statuses.Close || info.Status.ID == RequestInfo.Statuses.Pending || info.Status.ID == RequestInfo.Statuses.Responded)
            {
                requestInfo.Status.ID = info.Status.ID;
            }
            requestInfo.Priority.ID = dispatchInfo.Urgency.ID;

            this.requestDao.UpdateRequest(requestInfo);

            dispatchInfo.Status.ID = DispatchInfo.Statuses.New;
            dispatchInfo.ID        = this.dispatchDao.AddDispatch(dispatchInfo).ID;
            //添加历史操作——请求 派工
            HistoryInfo historyRequest = new HistoryInfo(requestInfo.ID, ObjectTypes.Request, user.ID, RequestInfo.Actions.Allocate);

            this.historyDao.AddHistory(historyRequest);

            //添加历史操作——派工单 新增
            HistoryInfo historyDisptach = new HistoryInfo(dispatchInfo.ID, ObjectTypes.Dispatch, user.ID, DispatchInfo.Actions.New, dispatchInfo.LeaderComments);

            this.historyDao.AddHistory(historyDisptach);

            UserInfo adminUser = this.userDao.GetUser(dispatchInfo.Engineer.ID);

            if (!string.IsNullOrEmpty(adminUser.RegistrationID))
            {
                Task.Factory.StartNew(() =>
                {
                    JPushManager.PushMessage(string.Format("您有新的派工, 派工单号:{0},请及时响应", dispatchInfo.OID), new List <string> {
                        adminUser.RegistrationID
                    });
                });
            }
        }
Ejemplo n.º 2
0
        public int AddRequest(RequestInfo info, List <UploadFileInfo> files, UserInfo user)
        {
            info.ID = this.requestDao.AddRequest(info);

            if (info.Equipments != null)
            {
                foreach (EquipmentInfo eqptInfo in info.Equipments)
                {
                    this.requestDao.AddRequestEqpt(info.ID, eqptInfo.ID);
                }
            }

            if (files != null && files.Count > 0)
            {
                foreach (UploadFileInfo file in files)
                {
                    file.ObjectID   = info.ID;
                    file.ObjectName = ObjectTypes.Request;
                    this.fileManager.SaveUploadFile(file);
                }
            }

            //添加历史操作——请求 新增
            if (user != null)
            {
                HistoryInfo history = new HistoryInfo(info.ID, ObjectTypes.Request, user.ID, RequestInfo.Actions.New);
                this.historyDao.AddHistory(history);
            }

            //send app message
            if (info.Source.ID == RequestInfo.Sources.CustomerRequest && info.RequestType.ID == RequestInfo.RequestTypes.Repair)
            {
                info = GetRequest(info.ID);
                List <UserInfo> superAdminUsers = this.userDao.GetActiveUsers(new List <int> {
                    UserRole.SuperAdmin
                });
                List <string> registrationIds = SQLUtil.GetStringListFromObjectList(superAdminUsers, "RegistrationID", false);
                if (registrationIds.Count > 0)
                {
                    Task.Factory.StartNew(() =>
                    {
                        JPushManager.PushMessage(string.Format("您有新的请求,科室:{0},设备名称:{1},设备序列号:{2},请及时派工", info.Equipments[0].Department.Name, info.Equipments[0].Name, info.Equipments[0].SerialCode), registrationIds);
                    });
                }
            }

            return(info.ID);
        }