Example #1
0
        public ActionResult MultiCancelDelivery(string ids)
        {
            var active = ResSettings.SettingsInSession.Actives.First();

            if (!active.IsInDeliveryPeriod)
            {
                var errormsg = "当前不在推送周期内,请联系统管理员!";
                return((ActionResult)Json(new { error = "error", msg = errormsg }));
            }

            var user    = ResSettings.SettingsInSession.User;
            var dr      = APDBDef.DeliveryRecord;
            var idArray = ConvertByString(ids);

            APBplDef.DeliveryRecordBpl.ConditionDelete(dr.ResourceId.In(idArray));
            foreach (var id in idArray)
            {
                APBplDef.CroResourceBpl.UpdatePartial(id, new { DeliveryStatus = CroResourceHelper.NotDelivery });
            }

            var maxCount      = ResDeliveryHelper.GetMaxAllowCount(user.ProvinceId, user.AreaId);
            var courrentCount = ResDeliveryHelper.GetDeliveryCount(user.ProvinceId, user.AreaId, db);

            return(Json(new { cmd = "Processed", msg = "取消报送完成", data = new { maxCount, courrentCount } }));
        }
Example #2
0
        public ActionResult MultiDelivery(string ids)
        {
            var active = ResSettings.SettingsInSession.Actives.First();

            if (!active.IsInDeliveryPeriod)
            {
                var errormsg = "当前不在推送周期内,请联系统管理员!";
                return((ActionResult)Json(new { error = "error", msg = errormsg }));
            }

            long deliveryType = 0;
            var  user         = ResSettings.SettingsInSession.User;
            var  dr           = APDBDef.DeliveryRecord;
            var  idArray      = ConvertByString(ids);

            var maxCount = ResDeliveryHelper.GetMaxAllowCount(user.ProvinceId, user.AreaId);
            var result   = ResDeliveryHelper.IsExccedMaxCount(user.ProvinceId, user.AreaId, maxCount, db);

            if (result)
            {
                return(Json(new { cmd = "error", msg = "已经超出最大报送数量" }));
            }

            if (user.UserTypePKID == ResUserHelper.ProvinceAdmin)
            {
                deliveryType = CroResourceHelper.ProviceLevelDelivery;
            }
            if (user.UserTypePKID == ResUserHelper.CityAdmin)
            {
                deliveryType = CroResourceHelper.CityLevelDelivery;
            }


            db.BeginTrans();

            try
            {
                db.DeliveryRecordDal.ConditionDelete(dr.ResourceId.In(idArray));

                foreach (var id in idArray)
                {
                    db.DeliveryRecordDal.Insert(new DeliveryRecord {
                        DeliveryTypePKID = deliveryType, Recorder = user.Id, ResourceId = id, AddTime = DateTime.Now
                    });
                    db.CroResourceDal.UpdatePartial(id, new { DeliveryStatus = CroResourceHelper.IsDelivery });
                }

                db.Commit();
            }
            catch
            {
                db.Rollback();

                return(Json(new { cmd = "error", msg = "批量报送失败" }));
            }

            var courrentCount = ResDeliveryHelper.GetDeliveryCount(user.ProvinceId, user.AreaId, db);

            return(Json(new { cmd = "Processed", msg = "批量报送完成", data = new { maxCount, courrentCount } }));
        }