Exemple #1
0
        public override ActionResult DelSubmit(FormCollection fm)
        {
            XCLNetTools.Message.MessageModel msg = new XCLNetTools.Message.MessageModel();
            var bll = new XCLCMS.Data.BLL.Attachment();
            var ids = (XCLNetTools.StringHander.FormHelper.GetString("attachmentIDs") ?? "").Split(',').ToList().ConvertAll(k => XCLNetTools.Common.DataTypeConvert.ToLong(k));

            if (null == ids || ids.Count == 0)
            {
                msg.IsSuccess = false;
                msg.Message   = "请指定要删除的记录!";
                return(Json(msg));
            }

            if (XCLCMS.Lib.Permission.PerHelper.IsOnlyCurrentMerchant(base.UserID))
            {
                foreach (var id in ids)
                {
                    var model = bll.GetModel(id);
                    if (null == model)
                    {
                        continue;
                    }
                    if (model.FK_MerchantID != base.CurrentUserModel.FK_MerchantID)
                    {
                        throw new Exception("只能删除自己的商户数据!");
                    }
                }
            }

            if (bll.Delete(ids, base.ContextModel))
            {
                msg.IsSuccess = true;
                msg.Message   = "删除成功!";
                msg.IsRefresh = true;

                //删除物理文件
                foreach (var id in ids)
                {
                    var model = bll.GetModel(id);
                    if (null == model)
                    {
                        continue;
                    }
                    if (string.IsNullOrWhiteSpace(model.URL))
                    {
                        continue;
                    }
                    XCLNetTools.FileHandler.ComFile.DeleteFile(Server.MapPath(model.URL));
                }
            }
            else
            {
                msg.IsSuccess = false;
                msg.Message   = "删除失败!";
            }
            return(Json(msg));
        }
Exemple #2
0
        public override ActionResult UpdateSubmit(FormCollection fm)
        {
            XCLNetTools.Message.MessageModel msg = new XCLNetTools.Message.MessageModel();
            var  bll          = new XCLCMS.Data.BLL.Attachment();
            long attachmentID = XCLNetTools.StringHander.FormHelper.GetLong("AttachmentID");
            var  model        = bll.GetModel(attachmentID);

            if (null == model)
            {
                msg.IsSuccess = false;
                msg.Message   = "未找到该记录!";
                return(Json(msg));
            }
            model.Title       = XCLNetTools.StringHander.FormHelper.GetString("Title");
            model.Description = XCLNetTools.StringHander.FormHelper.GetString("Description");
            model.UpdaterID   = base.UserID;
            model.UpdaterName = base.CurrentUserModel.UserName;
            model.UpdateTime  = DateTime.Now;
            if (bll.Update(model))
            {
                msg.IsSuccess = true;
                msg.Message   = "更新成功!";
            }
            else
            {
                msg.IsSuccess = false;
                msg.Message   = "更新失败!";
            }
            return(Json(msg));
        }
Exemple #3
0
        /// <summary>
        /// 查询附件信息实体
        /// </summary>
        public APIResponseEntity <XCLCMS.Data.Model.Attachment> Detail(APIRequestEntity <long> request)
        {
            var response = new APIResponseEntity <XCLCMS.Data.Model.Attachment>();

            response.Body      = attachmentBLL.GetModel(request.Body);
            response.IsSuccess = true;
            return(response);
        }
Exemple #4
0
        public ActionResult Update()
        {
            var bll = new XCLCMS.Data.BLL.Attachment();

            XCLCMS.FileManager.Models.LogicFile.UpdateVM viewModel = new Models.LogicFile.UpdateVM();
            viewModel.AttachmentID = XCLNetTools.StringHander.FormHelper.GetLong("AttachmentID");
            viewModel.Attachment   = bll.GetModel(viewModel.AttachmentID) ?? new Data.Model.Attachment();
            return(View(viewModel));
        }
Exemple #5
0
        public ActionResult Show()
        {
            var bll = new XCLCMS.Data.BLL.Attachment();

            XCLCMS.FileManager.Models.LogicFile.ShowVM viewModel = new Models.LogicFile.ShowVM();
            viewModel.AttachmentID = XCLNetTools.StringHander.FormHelper.GetLong("AttachmentID");
            viewModel.Attachment   = bll.GetModel(viewModel.AttachmentID) ?? new Data.Model.Attachment();
            if (viewModel.Attachment.AttachmentID > 0)
            {
                viewModel.SubAttachmentList = bll.GetCorrelativeList(viewModel.Attachment.AttachmentID);
            }
            return(View(viewModel));
        }
Exemple #6
0
        public async Task <APIResponseEntity <XCLCMS.Data.Model.Attachment> > Detail([FromUri] APIRequestEntity <long> request)
        {
            return(await Task.Run(() =>
            {
                var response = new APIResponseEntity <XCLCMS.Data.Model.Attachment>();
                response.Body = attachmentBLL.GetModel(request.Body);
                response.IsSuccess = true;

                //限制商户
                if (base.IsOnlyCurrentMerchant && null != response.Body && response.Body.FK_MerchantID != base.CurrentUserModel.FK_MerchantID)
                {
                    response.Body = null;
                    response.IsSuccess = false;
                }

                return response;
            }));
        }
        /// <summary>
        /// 查看附件
        /// </summary>
        public ActionResult ShowAttachment(long?id)
        {
            if (!id.HasValue || id.Value <= 0)
            {
                XCLNetTools.StringHander.Common.ResponseClearWrite("请指定有效的附件ID!");
                return(null);
            }

            string path  = string.Empty;
            var    model = attachmentBLL.GetModel(id.Value);

            if (null == model)
            {
                XCLNetTools.StringHander.Common.ResponseClearWrite("文件不存在,或已被删除!");
                return(null);
            }
            path = model.URL;
            if (string.IsNullOrWhiteSpace(path))
            {
                XCLNetTools.StringHander.Common.ResponseClearWrite("文件路径不存在!");
                return(null);
            }
            return(Redirect(XCLCMS.Lib.Common.Comm.GetAttachmentAbsoluteURL(path)));
        }