Ejemplo n.º 1
0
        public JsonResult Add(MsgViewModel model)
        {
            ResultRetrun rmodel = new ResultRetrun();

            if (!ValidateHelper.IsDateTime(model.OrderDate))
            {
                rmodel.message = "订单日期输入有误";
            }

            if (ModelState.IsValid)
            {
                MessageRecord msgModel = new MessageRecord()
                {
                    MessageId  = model.Number,
                    OperatorId = UserId,
                    SendState  = MsgSendState.Unsent,
                    ToAddress  = model.Phone,
                    MsgData    = new MsgDataInfo()
                    {
                        OrderDate = Convert.ToDateTime(model.OrderDate), OrderName = model.OrderName
                    }
                };
                rmodel.isSuccess = msgService.Add(msgModel);
            }

            return(Json(rmodel));
        }
Ejemplo n.º 2
0
        private List <MessageRecord> GetSheetData(ISheet sheet)
        {
            List <MessageRecord> msgRecordList = null;
            const int            minrownum     = 1;//最小行数,如果小于1行证明sheet无数据

            if (sheet != null && sheet.LastRowNum >= minrownum)
            {
                int startrownum = 1;//从第2行开始取数据(row和cell从0开始)
                int endrownum   = sheet.LastRowNum;
                msgRecordList = new List <MessageRecord>();
                MessageRecord msgRecordInfo = null;
                for (int index = startrownum; index <= endrownum; index++)
                {
                    IRow row = sheet.GetRow(index);
                    if (row == null)
                    {
                        continue;
                    }

                    string orderDataStr = CellSwitch(row.GetCell(3));
                    msgRecordInfo = new MessageRecord()
                    {
                        MessageId  = Regex.Replace(CellSwitch(row.GetCell(0)), @"\s", ""),
                        ToAddress  = Regex.Replace(CellSwitch(row.GetCell(2)), @"\s", ""),
                        SendState  = MsgSendState.Unsent,
                        OperatorId = UserId,
                        MsgData    = new MsgDataInfo()
                        {
                            OrderDate = ValidateHelper.IsDateTime(orderDataStr) ? Convert.ToDateTime(orderDataStr) : DateTime.MinValue, OrderName = Regex.Replace(CellSwitch(row.GetCell(1)), @"\s", "")
                        }
                    };

                    if (CheckMsg(msgRecordInfo))
                    {
                        msgRecordList.Add(msgRecordInfo);
                    }
                }
            }

            return(msgRecordList);
        }
Ejemplo n.º 3
0
        public JsonResult Edit(MsgViewModel model)
        {
            ResultRetrun rmodel = new ResultRetrun();

            if (!ValidateHelper.IsDateTime(model.OrderDate))
            {
                rmodel.message = "订单日期输入有误";
            }

            if (ModelState.IsValid)
            {
                MessageRecord data = msgService.Get(model.Id);
                data.MessageId         = model.Number;
                data.ToAddress         = model.Phone;
                data.MsgData.OrderName = model.OrderName;
                data.MsgData.OrderDate = Convert.ToDateTime(model.OrderDate);
                data.OperatorId        = UserId;
                rmodel.isSuccess       = msgService.Update(data);
            }

            return(Json(rmodel));
        }