private void TranslateAllMessageEntityToAllMessageContractData(
     AllMessageEntity allMessageEntity,
     AllMessage allMessage) {
     allMessage.ErrorMessage = allMessageEntity.ErrorMessage;
     allMessage.Count = allMessageEntity.Count;
     if (allMessage.Count > 0) {
         allMessage.message = new Message[allMessage.Count];
         for (int i = 0; i < allMessage.Count; i++) {
             allMessage.message[i] = new Message();
             allMessage.message[i].ErrorMessage = allMessageEntity.messageEntity[i].ErrorMessage;
             allMessage.message[i].Date = allMessageEntity.messageEntity[i].Date;
             allMessage.message[i].Sender = allMessageEntity.messageEntity[i].Sender;
             allMessage.message[i].Receiver = allMessageEntity.messageEntity[i].Receiver;
             allMessage.message[i].Status = allMessageEntity.messageEntity[i].Status;
             allMessage.message[i].Context = allMessageEntity.messageEntity[i].Context;
         }
     }
 }
Пример #2
0
        /*医生查看发件箱*/
        public AllMessageEntity MessageSent(string doctorID, DateTime? startDate, DateTime? endDate) {
            DrPEDatabaseEntities DEntities = new DrPEDatabaseEntities();
            AllMessageEntity allMessageEntity = new AllMessageEntity();

            /*提交查询*/
            Doctor doctor = (from d in DEntities.Doctors
                             where d.DoctorID == doctorID
                             select d).FirstOrDefault();
            if (doctor == null) {
                allMessageEntity.ErrorMessage = "Invalid Sender DoctorID! @Data";
                return allMessageEntity;
            }

            var messages = from m in DEntities.Messages
                           where ((m.Sender == doctorID) && (startDate <= m.Date) && (m.Date <= endDate))
                           orderby m.Date descending
                           select m;

            /*处理无结果的情况*/
            int messageCount = messages.Count();
            if (messageCount <= 0) {
                allMessageEntity.ErrorMessage = String.Format("Doctor {0} Sent No Messages Between {1} and {2}! @Data",
                                                                doctor.DoctorID, startDate, endDate);
                return allMessageEntity;
            }

            int cnt = 0;
            allMessageEntity.Count = messageCount;
            allMessageEntity.messageEntity = new MessageEntity[messageCount];
            foreach (var m in messages) {
                allMessageEntity.messageEntity[cnt] = new MessageEntity();
                allMessageEntity.messageEntity[cnt].MessageID = m.MessageID;
                allMessageEntity.messageEntity[cnt].Sender = m.Sender;
                allMessageEntity.messageEntity[cnt].Receiver = m.Receiver;
                allMessageEntity.messageEntity[cnt].Status = m.Type;
                allMessageEntity.messageEntity[cnt].Date = m.Date;
                allMessageEntity.messageEntity[cnt].Context = m.Text;
                cnt++;
            }

            return allMessageEntity;
        }
        /*医生查看发件箱*/
        public AllMessage MessageSent(DateTime? startDate, DateTime? endDate) {
            AllMessageEntity allMessageEntity = null;

            if (startDate == null) {
                allMessageEntity = new AllMessageEntity();
                allMessageEntity.ErrorMessage = "Start Date! @Service";
            }
            else if (endDate == null) {
                allMessageEntity = new AllMessageEntity();
                allMessageEntity.ErrorMessage = "End Date! @Service";
            }
            else {
                allMessageEntity = doctorLogic.MessageSent(startDate, endDate);
            }
            AllMessage allMessage = new AllMessage();
            TranslateAllMessageEntityToAllMessageContractData(allMessageEntity, allMessage);

            return allMessage;
        }
Пример #4
0
 /*医生查看发件箱*/
 public AllMessageEntity MessageSent(DateTime? startDate, DateTime? endDate) {
     if (confirmed == false) {
         AllMessageEntity allMessageEntity = new AllMessageEntity();
         allMessageEntity.ErrorMessage = "Not Logged in Yet! @Logic";
         return allMessageEntity;
     }
     else {
         return doctorDAO.MessageSent(confirmedDoctorID, startDate, endDate);
     }
 }