Пример #1
0
        protected override IEnumerable <SendMessageRuleModel> ConvertModel(IEnumerable <SendMessageRuleModel> models)
        {
            foreach (var model in models)
            {
                SendMessageRuleProfile.ConvertModel(model);
            }

            return(models);
        }
Пример #2
0
        protected override ReportDownloadModel ProduceFile(MessageReceiverCriteriaModel criteria, IEnumerable <MessageReceiverModel> models)
        {
            var sendMessageRule      = context.Set <SendMessageRule>().Find(criteria.SendMessageRuleId);
            var sendMessageRuleModel = Mapper.Map <SendMessageRule, SendMessageRuleModel>(sendMessageRule);

            sendMessageRuleModel = SendMessageRuleProfile.ConvertModel(sendMessageRuleModel);

            var sendTimeType = sendMessageRule.SendTimeType;

            switch (sendTimeType)
            {
            case SendTimeType.Deliver:
            {
                TimeSpan clientTimezoneOffset = ClientTimezoneOffset;
                string   timeFormat           = Converter.Every8d_SentTime;

                var result = models.Select(p => new
                    {
                        息類型   = p.SendMessageType == SendMessageType.SmsMessage ? "SMS" : "APP",
                        收訊者姓名 = p.Name,
                        收訊者門號 = p.Mobile,
                        預約時間  = Converter.ToLocalTimeString(sendMessageRuleModel.SendTime.Value, clientTimezoneOffset, timeFormat),
                        發送扣點  = p.MessageCost,
                    });
                return(ProduceExcelFile(
                           fileName: "預約簡訊收訊人名單.xlsx",
                           sheetName: "預約簡訊收訊人名單",
                           models: result));
            }

            case SendTimeType.Cycle:
            {
                var result = models.Select(p => new
                    {
                        息類型   = p.SendMessageType == SendMessageType.SmsMessage ? "SMS" : "APP",
                        收訊者姓名 = p.Name,
                        收訊者門號 = p.Mobile,
                        收訊者信箱 = p.Email,
                        //預約時間 = sendMessageRuleModel.SendTimeString,
                        發送扣點 = p.MessageCost,
                    });
                return(ProduceExcelFile(
                           fileName: "週期簡訊收訊人名單.xlsx",
                           sheetName: "週期簡訊收訊人名單",
                           models: result));
            }

            default:
                throw new Exception(string.Format("Unknown SendTimeType({0}", sendTimeType));
            }
        }