示例#1
0
        public ActionResult SetExpStatus(int id, int state)
        {
            //var m = model;
            try
            {
                ExpStateEnum s = (ExpStateEnum)state;
                using (yxbDbContext con = new yxbDbContext())
                {
                    var model = con.ExpList.Single(o => o.ExpId == id);
                    //时间戳
                    model.ExpTime = DateTime.Now;
                    //var list = con.ExpList.AsNoTracking().Where(o => o.ExpId == model.ExpId).ToList();
                    model.ExpState = state;
                    con.Entry(model).State = System.Data.Entity.EntityState.Modified;
                    ExpContext econtext = new ExpContext();
                    econtext.expid = model.ExpId;
                    econtext.expno = model.ExpNo;
                    econtext.time = DateTime.Now;
                    switch (s)
                    {
                        case ExpStateEnum.OnDistribute:
                            econtext.context = "派件扫描";
                            con.ExpContext.Add(econtext);
                            con.SaveChanges();
                            break;
                        case ExpStateEnum.OnSign:
                            econtext.context = "货物已签收";
                            con.ExpContext.Add(econtext);
                            con.SaveChanges();
                            //短信模板参数
                            List<string> smsdata = new List<string>();
                            smsdata.Add(model.From);
                            smsdata.Add(model.To);
                            smsdata.Add(model.ExpNo);
                            smsdata.Add(ExpSMSTemp.ContactTel);

                            SendExpSMS ss = new SendExpSMS();
                            if (!string.IsNullOrWhiteSpace(model.From))
                            {
                                ExpSMSResponse ret = ss.SendSMS(model.ToMobile, ExpSMSTemp.SignTempId, smsdata.ToArray());
                            }
                            break;
                        default:
                            return Json(CommenData.ResultMsg(-1, "标记失败"), JsonRequestBehavior.AllowGet);
                    }
                }
                return Json(CommenData.ResultMsg(1, "标记成功"), JsonRequestBehavior.AllowGet);
            }
            catch (Exception ex)
            {
                return Json(CommenData.ResultMsg(-1, ex.Message), JsonRequestBehavior.AllowGet);
            }

        }
示例#2
0
        public ActionResult SaveExp(ExpList model)
        {
            //var m = model;
            try
            {
                using (yxbDbContext con = new yxbDbContext())
                {
                    //时间戳
                    model.ExpTime = DateTime.Now;
                    var list = con.ExpList.AsNoTracking().Where(o => o.ExpId == model.ExpId && o.IsDeleted == 0).ToList();
                    if (list.Count() > 0)
                    {
                        var exist = con.ExpList.AsNoTracking().Where(o => o.ExpNo == model.ExpNo && o.ExpId != model.ExpId && o.IsDeleted == 0);
                        if (exist.Count() > 0)
                        {
                            return Json(CommenData.ResultMsg(2, "该单号已录入,请查证后输入。"), JsonRequestBehavior.AllowGet);
                        }
                        else
                        {
                            con.Entry(model).State = System.Data.Entity.EntityState.Modified;
                            // int expno = list.First();

                            List<ExpContext> expdetail = con.ExpContext.Where(o => o.expid == model.ExpId).ToList();
                            foreach (ExpContext ec in expdetail)
                            {
                                ec.expno = model.ExpNo;
                            }


                            con.SaveChanges();

                            //签收短信通知
                            ExpStateEnum s = (ExpStateEnum)model.ExpState;
                            switch (s)
                            {
                                case ExpStateEnum.OnSign:
                                    //短信模板参数
                                    List<string> smsdata = new List<string>();
                                    smsdata.Add(model.From);
                                    smsdata.Add(model.To);
                                    smsdata.Add(model.ExpNo);
                                    smsdata.Add(ExpSMSTemp.ContactTel);

                                    SendExpSMS ss = new SendExpSMS();
                                    if (!string.IsNullOrWhiteSpace(model.From))
                                    {
                                        ExpSMSResponse ret = ss.SendSMS(model.ToMobile, ExpSMSTemp.SignTempId, smsdata.ToArray());
                                    }
                                    break;
                            }
                            return Json(CommenData.ResultMsg(1, "信息修改成功"), JsonRequestBehavior.AllowGet);

                        }
                    }
                    else
                    {
                        var exist = con.ExpList.AsNoTracking().Where(o => o.ExpNo == model.ExpNo && o.IsDeleted == 0);
                        if (exist.Count() > 0)
                        {
                            return Json(CommenData.ResultMsg(2, "该单号已录入,请查证后输入。"), JsonRequestBehavior.AllowGet);
                        }
                        else
                        {
                            con.ExpList.Add(model);

                            con.SaveChanges();
                            //添加详情
                            ExpContext expDetail = new ExpContext();
                            expDetail.expno = model.ExpNo;
                            expDetail.context = "揽件扫描";
                            expDetail.time = DateTime.Now;
                            expDetail.expid = model.ExpId;


                            con.ExpContext.Add(expDetail);
                            con.SaveChanges();
                            //短信模板参数
                            List<string> smsdata = new List<string>();
                            smsdata.Add(model.StartStation);
                            smsdata.Add(model.ExpNo);
                            smsdata.Add(ExpSMSTemp.ContactTel);

                            SendExpSMS ss = new SendExpSMS();
                            ExpSMSResponse ret = ss.SendSMS(model.ToMobile, ExpSMSTemp.SendTempId, smsdata.ToArray());

                            return Json(CommenData.ResultMsg(1, ""), JsonRequestBehavior.AllowGet);

                        }

                    }
                }
            }
            catch (Exception ex)
            {
                return Json(CommenData.ResultMsg(-1, ex.Message), JsonRequestBehavior.AllowGet);
            }

        }