Exemple #1
0
        private ResultInfo UpLoadFile(string uploadPath, ImgExtTypeEnum imgExt, bool isThumbnail = false, bool size1M = true)
        {
            ResultInfo         ri          = new ResultInfo();
            string             delFilePath = Request.Params["DelFilePath"];
            string             type        = Request.Params["itype"];
            HttpPostedFileBase upfile      = Request.Files["file"];

            if (upfile == null)
            {
                ri.Msg = "请选择要上传的文件";
                return(ri);
            }

            int aid = IsLogin ? (int)UserID : 0;

            ri = FileSaveAs(upfile, imgExt, isThumbnail, aid, uploadPath, type, size1M);

            //删除已存在的旧文件,旧文件不为空且应是上次文件,防止跨目录删除
            if (!string.IsNullOrEmpty(delFilePath) && delFilePath.IndexOf("../", StringComparison.Ordinal) == -1)
            {
                UploadHelper.DeleteUpFile(delFilePath);
            }

            return(ri);
        }
Exemple #2
0
        public ActionResult UploadHead()
        {
            ResultInfo result = UpLoadFile(headurlPath, ImgExtTypeEnum.jpg, true);

            if (result.Ok)
            {
                var user = UserBaseBLL.Instance.GetUserInfo(UserID);

                if (user.HeadUrl.IsNotNullOrEmpty())
                {
                    string oldHeadUrl      = user.HeadUrl;
                    string oldThumbHeadUrl = oldHeadUrl.Replace(UserID.ToString(), "thumb/{0}".FormatWith(UserID));
                    UploadHelper.DeleteUpFile(oldHeadUrl);
                    UploadHelper.DeleteUpFile(oldThumbHeadUrl);
                }
                //更新头像
                result.Ok = UserBaseBLL.Instance.UploadHeadUrl(result.Data.ToString(), UserID);
            }

            var model = UserBaseBLL.Instance.GetModel(UserInfo.UserID);

            SetLogin(model);

            return(Result(result));
        }
        public ActionResult Edit(Product model)
        {
            ResultInfo ri = new ResultInfo();

            if (ModelState.IsValid)
            {
                Product _model = ProductBLL.Instance.GetModel(model.ProductID);
                if (_model == null)
                {
                    ri.Msg = "该产品已被删除";
                }
                else
                {
                    Action <string> action = (imagePath) =>
                    {
                        _model.CompanyName = model.CompanyName;
                        _model.PTitle      = model.PTitle;
                        _model.PLocation   = model.PLocation;
                        _model.PDesc       = model.PDesc;
                        _model.PFunction   = model.PFunction;
                        _model.PPrice      = model.PPrice;
                        _model.PSize       = model.PSize;
                        _model.Contact     = model.Contact;
                        _model.ProductPic  = imagePath;
                        _model.PUnit       = model.PUnit;
                        _model.PWeight     = model.PWeight;
                        _model.SendDay     = model.SendDay;
                        _model.UpdateUser  = UserID.ToString();
                        _model.UpdateTime  = DateTime.Now;

                        ri = ProductBLL.Instance.Update(_model);
                        if (ri.Ok)
                        {
                            ri.Url = ConfigHelper.AppSettings("ProductDetail").FormatWith(_model.ProductID);
                        }
                    };
                    //是否修改上传照片
                    if (GetRequest <bool>("ischange"))
                    {
                        string oldImagePath = _model.ProductPic;
                        ri = UpLoadImg("ProductPic", "/Content/Job/CP");
                        if (ri.Ok)
                        {
                            action(ri.Url);
                            UploadHelper.DeleteUpFile(oldImagePath);
                        }
                    }
                    else
                    {
                        action(_model.ProductPic);
                    }
                }
            }
            return(Result(ri));
        }
Exemple #4
0
        public ActionResult UploadVipHead()
        {
            ResultInfo ri = UpLoadFile(vipheadurlPath, ImgExtTypeEnum.gif, false, false);

            if (ri.Ok)
            {
                //管理员可以直接免审核
                if (UserBaseBLL.Instance.IsMaster)
                {
                    var model = UserBaseBLL.Instance.GetModel(UserInfo.UserID);
                    if (model.HeadUrl.IsNotNullOrEmpty())
                    {
                        string oldHeadUrl      = model.HeadUrl;
                        string oldThumbHeadUrl = oldHeadUrl.Replace(UserID.ToString(), "thumb/{0}".FormatWith(UserID));
                        UploadHelper.DeleteUpFile(oldHeadUrl);
                        UploadHelper.DeleteUpFile(oldThumbHeadUrl);
                    }
                    //更新头像
                    UserBaseBLL.Instance.UploadHeadUrl(ri.Url, UserID);
                    model.HeadUrl = ri.Url;
                    SetLogin(model);
                }
                else
                {
                    //待审核
                    VIPHead model = new VIPHead()
                    {
                        CreateTime = DateTime.Now,
                        HeadUrl    = ri.Url,
                        IsChecked  = 0,
                        IsDelete   = 0,
                        UserID     = UserID,
                    };
                    ri = new ResultInfo();
                    if (VIPHeadBLL.Instance.Add(model) > 0)
                    {
                        ri.Ok = true;
                    }
                }
            }
            return(Result(ri));
        }
        public ActionResult Publish(QiuZhi model, int deadTime, bool hasPic)
        {
            ResultInfo ri = CheckEmpty(model);

            if (ri.Ok)
            {
                ri = UpLoadImg("JianLiPic", "/Content/Job/QZ", beforeSaveFile: (save, resultInfo) =>
                {
                    try
                    {
                        BeginTran();
                        //判断VIP分是否足够
                        int publishScore = Convert.ToInt32(ConfigHelper.AppSettings("PUBLISH_QIUZHI"));
                        int type         = 2;
                        if (UserExtBLL.Instance.HasEnoughCoin(type, publishScore, UserID))
                        {
                            //扣除相应积分
                            if (UserExtBLL.Instance.SubScore(UserID, publishScore, type, Tran))
                            {
                                if (ScoreCoinLogBLL.Instance.Log(-publishScore, type, CoinSourceEnum.PublishQiuZhi, UserID, UserInfo.UserName, Tran))
                                {
                                    if (hasPic)
                                    {
                                        resultInfo = save();
                                    }

                                    if (model.WorkType == 1)
                                    {
                                        model.WorkTime = null;
                                    }

                                    model.ValidTime  = DateTime.Now.AddDays(deadTime);
                                    model.UpdateTime = DateTime.Now;
                                    model.CreateTime = DateTime.Now;
                                    model.UpdateUser = UserID.ToString();
                                    model.Publisher  = UserID.ToString();
                                    model.IsDelete   = 0;
                                    model.JianLiPic  = resultInfo?.Url;
                                    model.IsTop      = 0;
                                    model.IsJinghua  = 0;
                                    model.IsRemen    = 0;
                                    model.PVCount    = 0;

                                    int result = QiuZhiBLL.Instance.Add(model);

                                    if (result > 0)
                                    {
                                        string uri     = ConfigHelper.AppSettings("QiuZhiDetail").FormatWith(result);
                                        resultInfo.Url = uri;
                                        resultInfo.Ok  = true;
                                        Commit();

                                        //通知作者
                                        NoticeBLL.Instance.OnPayPublish_Notice_Author(UserID, DateTime.Now, GetDomainName + uri, model.IWant, 20, publishScore.ToString(), NoticeTypeEnum.QiuZhi_Pay_Publish);
                                        //通知关注作者的用户
                                        NoticeBLL.Instance.OnAdd_Notice_Liker(UserInfo.UserName, UserID, uri, model.IWant, NoticeTypeEnum.QiuZhi_Add, GetDomainName);
                                    }
                                    else
                                    {
                                        resultInfo.Msg = "发布失败";
                                        RollBack();
                                        UploadHelper.DeleteUpFile(resultInfo.Url);
                                    }
                                }
                                else
                                {
                                    RollBack();
                                    resultInfo.Msg = "发布失败";
                                }
                            }
                            else
                            {
                                RollBack();
                                resultInfo.Msg = "发布失败";
                            }
                        }
                        else
                        {
                            resultInfo.Msg = "VIP分不足,请去个人中心充值";
                        }
                    }
                    catch
                    {
                        resultInfo.Msg = "发布异常 ";
                        RollBack();
                        UploadHelper.DeleteUpFile(resultInfo.Url);
                    }
                }, isNeedFile: hasPic);
            }
            return(Result(ri));
        }
        public ActionResult Edit(QiuZhi model, int deadTime)
        {
            ResultInfo ri = new ResultInfo();

            if (ModelState.IsValid)
            {
                ri = CheckEmpty(model);
                if (ri.Ok)
                {
                    QiuZhi _model = QiuZhiBLL.Instance.GetModel(model.QiuZhiID);
                    if (_model == null)
                    {
                        ri.Msg = "该求职信息已被删除";
                    }
                    else
                    {
                        Action <string> action = (imagePath) =>
                        {
                            _model.IWant          = model.IWant;
                            _model.Money          = model.Money;
                            _model.NowWork        = model.NowWork;
                            _model.WorkStatus     = model.WorkStatus;
                            _model.Study          = model.Study;
                            _model.WorkYear       = model.WorkYear;
                            _model.MyDesc         = model.MyDesc;
                            _model.Contact        = model.Contact;
                            _model.SelfAssessment = model.SelfAssessment;
                            _model.JianLiPic      = imagePath;
                            _model.IWantPlace     = model.IWantPlace;
                            _model.BelongJob      = model.BelongJob;
                            _model.BelongJobTrade = model.BelongJobTrade;
                            _model.WorkType       = model.WorkType;
                            _model.WorkTime       = model.WorkTime;

                            _model.ValidTime  = DateTime.Now.AddDays(deadTime);
                            _model.UpdateTime = DateTime.Now;
                            if (_model.WorkType == 1)
                            {
                                _model.WorkTime = null;
                            }

                            ri = QiuZhiBLL.Instance.Update(_model);
                            if (ri.Ok)
                            {
                                ri.Url = ConfigHelper.AppSettings("QiuZhiDetail").FormatWith(_model.QiuZhiID);
                            }
                        };

                        //是否修改上传照片
                        if (GetRequest <bool>("ischange"))
                        {
                            string oldImagePath = _model.JianLiPic;
                            ri = UpLoadImg("JianLiPic", "/Content/Job/QZ");
                            if (ri.Ok)
                            {
                                action(ri.Url);
                                UploadHelper.DeleteUpFile(oldImagePath);
                            }
                        }
                        else
                        {
                            action(_model.JianLiPic);
                        }
                    }
                }
            }
            return(Result(ri));
        }
        public ActionResult Edit(long id, string title, string body)
        //public ActionResult Edit(long id, string title, string body, bool isdelete = false, bool ischanged = false)
        {
            ResultInfo ri     = new ResultInfo();
            Article    amodel = ArticleBLL.Instance.GetModel(id);

            if (amodel.EditCount < 3)
            {
                if (amodel.IsDelete == 0)
                {
                    //是否匿名、
                    bool isanonymous = GetRequest <bool>("isanonymous");

                    bool   contentNeedFee = GetRequest <bool>("contentNeedFee");
                    int    contentFeeType = GetRequest <int>("contentFeeType");
                    int    contentFee     = GetRequest <int>("contentFee");
                    string attachIndex    = GetRequest("attachIndexs");
                    var    fileFee        = JsonHelper.JsonToModel <List <FileFee> >("[" + GetRequest("fees") + "]");//附件费用

                    string   tagsrequest = GetRequest("tags");
                    string[] tags        = tagsrequest.IsNotNullOrEmpty() ? tagsrequest.Split(',') : null;

                    //var newri = new ResultInfo<AttachMent>() { Ok = true };
                    var fileOk = true;

                    //判断附件是否更改了。更改则先删除之前的再上传后来的
                    //if (ischanged || isdelete)
                    //{
                    //    UploadHelper.DeleteUpFile(amodel.FilePath);
                    //    if (ischanged)
                    //    {
                    //        newri = UpLoadFile(Request.Files["file"], "/Content/U/Art/FuJian", needValidatFile: false, rename: false);
                    //    }
                    //}

                    BeginTran();

                    List <AttachMent> attachMents_new = new List <AttachMent>();
                    List <string>     removePaths     = new List <string>();
                    try
                    {
                        #region 判断附件是否更改了。更改则先删除之前的再上传后来的
                        if (attachIndex.IsNotNullOrEmpty())
                        {
                            var attachIndexs = attachIndex.Split(',');

                            //原有附件ID
                            var maintype         = AttachEnumType.Article.GetHashCode();
                            var oldAttachMentIds = DB.AttachMent.Where(a => a.MainId == id && a.MainType == maintype).ToList();

                            oldAttachMentIds.ForEach(attach =>
                            {
                                if (fileFee.FirstOrDefault(a => a.AttachId == attach.AttachMentId) == null)
                                {
                                    removePaths.Add(attach.FilePath);
                                    DB.AttachMent.Remove(attach);
                                }
                            });

                            attachIndexs.ForEach(i =>
                            {
                                int _index  = i.ToInt32();
                                var feeinfo = fileFee.FirstOrDefault(fee => fee.Index == _index);
                                if (feeinfo != null)
                                {
                                    if (feeinfo.isNew)
                                    {
                                        //新增
                                        var file       = Request.Files["file" + i];
                                        var fileResult = UpLoadFile(file, "/Content/U/Art/FuJian", needValidatFile: false, rename: false);
                                        fileOk         = fileResult.Ok;
                                        if (fileResult.Ok)
                                        {
                                            attachMents_new.Add(new AttachMent()
                                            {
                                                AttachMentId = Guid.NewGuid(),
                                                CreateTime   = DateTime.Now,
                                                CreateUser   = UserID,
                                                DownCount    = 0,
                                                FileName     = fileResult.Data.FileName,
                                                FilePath     = fileResult.Data.FilePath,
                                                FileSize     = fileResult.Data.FileSize,
                                                MainType     = AttachEnumType.Article.GetHashCode(),
                                                IsDelete     = 0,
                                                FeeType      = feeinfo.FeeType,
                                                Fee          = feeinfo.Fee,
                                                IsFee        = feeinfo.FeeType != 0,
                                                MainId       = id
                                            });
                                        }
                                    }
                                    else if (feeinfo.IsChange || feeinfo.FeeTypeChange || feeinfo.FeeChange)
                                    {
                                        //替换
                                        var oldAttachModel = DB.AttachMent.FirstOrDefault(a => a.AttachMentId == feeinfo.AttachId);
                                        if (oldAttachModel != null)
                                        {
                                            if (feeinfo.IsChange)
                                            {
                                                //先保存后删除
                                                string oldPath = oldAttachModel.FilePath;
                                                var file       = Request.Files["file" + i];
                                                var fileResult = UpLoadFile(file, "/Content/U/Art/FuJian", needValidatFile: false, rename: false);
                                                fileOk         = fileResult.Ok;
                                                if (fileResult.Ok)
                                                {
                                                    oldAttachModel.FileName = fileResult.Data.FileName;
                                                    oldAttachModel.FileSize = fileResult.Data.FileSize;
                                                    oldAttachModel.FilePath = fileResult.Data.FilePath;
                                                    removePaths.Add(oldPath);
                                                }
                                            }
                                            if (feeinfo.FeeTypeChange)
                                            {
                                                oldAttachModel.FeeType = feeinfo.FeeType;
                                            }
                                            if (feeinfo.FeeChange)
                                            {
                                                oldAttachModel.Fee = feeinfo.Fee;
                                            }
                                        }
                                    }
                                }
                            });
                        }

                        #endregion

                        if (fileOk)
                        {
                            //添加新附件
                            if (QuestionBLL.Instance.AddAttachMent(attachMents_new, Tran))
                            {
                                //先将旧的标签全部删除,再新增编辑后的标签,不管有没有改变都这么执行
                                if (MenuBelongTagBLL.Instance.RemoveAndAddNew(id, 1038, CommentEnumType.Article, tags, Tran))
                                {
                                    amodel.Title = title;
                                    amodel.Body  = HttpUtility.UrlDecode(body);
                                    //amodel.FilePath = newri.Url;
                                    amodel.UpdateTime = DateTime.Now;
                                    amodel.UpdateUser = UserID.ToString();

                                    amodel.IsAnonymous = isanonymous;

                                    if (!UserBaseBLL.Instance.IsMaster)
                                    {
                                        ++amodel.EditCount;
                                    }

                                    amodel.ContentNeedPay = contentNeedFee;
                                    //内容付费
                                    if (contentNeedFee)
                                    {
                                        amodel.ContentFeeType = contentFeeType;
                                        amodel.ContentFee     = contentFee;
                                    }

                                    ri = ArticleBLL.Instance.Update(amodel, Tran);
                                    string uri = $"/article/detail/{id}";
                                    if (ri.Ok)
                                    {
                                        ri.Url = uri;
                                        Commit();
                                        DB.SaveChanges();
                                        //删除旧文件
                                        removePaths.ForEach(item =>
                                        {
                                            UploadHelper.DeleteUpFile(item);
                                        });
                                    }
                                    else
                                    {
                                        attachMents_new.ForEach(item =>
                                        {
                                            UploadHelper.DeleteUpFile(item.FilePath);
                                        });
                                        RollBack();
                                    }
                                }
                                else
                                {
                                    attachMents_new.ForEach(item =>
                                    {
                                        UploadHelper.DeleteUpFile(item.FilePath);
                                    });
                                    RollBack();
                                }
                            }
                            else
                            {
                                attachMents_new.ForEach(item =>
                                {
                                    UploadHelper.DeleteUpFile(item.FilePath);
                                });
                                RollBack();
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        attachMents_new.ForEach(item =>
                        {
                            UploadHelper.DeleteUpFile(item.FilePath);
                        });
                        RollBack();
                    }
                }
                else
                {
                    ri.Msg = "文章异常";
                }
            }
            else
            {
                ri.Msg = "该文章已被修改3次,不能再修改!请在留言区进行追问!";
            }
            return(Result(ri));
        }
        public ActionResult Publish(string title, string body)
        {
            ResultInfo ri = new ResultInfo();

            if (!string.IsNullOrEmpty(title))
            {
                if (!string.IsNullOrEmpty(body))
                {
                    //是否匿名、
                    bool isanonymous = GetRequest <bool>("isanonymous");

                    bool   contentNeedFee = GetRequest <bool>("contentNeedFee");
                    int    contentFeeType = GetRequest <int>("contentFeeType");
                    int    contentFee     = GetRequest <int>("contentFee");
                    string attachIndex    = GetRequest("attachIndexs");
                    var    fileFee        = JsonHelper.JsonToModel <List <FileFee> >("[" + GetRequest("fees") + "]");//附件费用

                    string   tagsrequest = GetRequest("tags");
                    string[] tags        = tagsrequest.IsNotNullOrEmpty() ? tagsrequest.Split(',') : null;

                    List <AttachMent> attachMents = new List <AttachMent>();
                    try
                    {
                        var fileOk = true;

                        #region 先上传附件再生成数据
                        if (attachIndex.IsNotNullOrEmpty())
                        {
                            var attachIndexs = attachIndex.Split(',');
                            attachIndexs.ForEach(i =>
                            {
                                var file       = Request.Files["file" + i];
                                var fileResult = UpLoadFile(file, "/Content/U/Art/FuJian", needValidatFile: false, rename: false);
                                fileOk         = fileResult.Ok;
                                if (fileResult.Ok)
                                {
                                    var attachment = new AttachMent
                                    {
                                        AttachMentId = Guid.NewGuid(),
                                        CreateTime   = DateTime.Now,
                                        CreateUser   = UserID,
                                        DownCount    = 0,
                                        FileName     = fileResult.Data.FileName,
                                        FilePath     = fileResult.Data.FilePath,
                                        FileSize     = fileResult.Data.FileSize,
                                        MainType     = AttachEnumType.Article.GetHashCode(),
                                        IsDelete     = 0
                                    };
                                    int _index        = i.ToInt32();
                                    var attachFeeInfo = fileFee.FirstOrDefault(a => a.Index == _index);
                                    if (attachFeeInfo != null)
                                    {
                                        attachment.FeeType = attachFeeInfo.FeeType;
                                        attachment.Fee     = attachFeeInfo.Fee;
                                        attachment.IsFee   = attachFeeInfo.FeeType != 0;
                                    }
                                    attachMents.Add(attachment);
                                }
                            });
                        }
                        #endregion

                        if (fileOk)
                        {
                            BeginTran();
                            Article model = new Article()
                            {
                                Body       = HttpUtility.UrlDecode(body),
                                CreateTime = DateTime.Now,
                                IsDelete   = 0,
                                Title      = title,
                                UserID     = UserID,
                                PVCount    = 0,
                                //FilePath = fileResultInfo.Url,
                                EditCount  = 0,
                                CreateUser = UserID.ToString(),
                                UpdateUser = UserID.ToString(),
                                UpdateTime = DateTime.Now,

                                IsAnonymous = isanonymous,
                            };

                            model.ContentNeedPay = contentNeedFee;
                            //内容付费
                            if (contentNeedFee)
                            {
                                model.ContentFeeType = contentFeeType;
                                model.ContentFee     = contentFee;
                            }

                            UserExt userext = UserExtBLL.Instance.GetExtInfo(UserID);

                            //先判断该用户是否被设置成了需要审核,如果没设置的话,再判断系统系统
                            if (userext.CheckBBS == 1)
                            {
                                model.IsChecked = 1;
                            }
                            else
                            {
                                //判断是否触发审核机制:积分大于1000分时,必须要参加审核
                                int mustcheckscore = Convert.ToInt32(ConfigHelper.AppSettings("MustCheckByScore"));
                                //积分大于多少时自动审核
                                int autocheckscore = Convert.ToInt32(ConfigHelper.AppSettings("AutoCheck_NeedScore"));
                                model.IsChecked = userext.TotalScore >= mustcheckscore ? userext.TotalScore <= autocheckscore ? 1 : 2 : 2;
                            }
                            int result = ArticleBLL.Instance.Add(model, Tran);
                            if (result > 0)
                            {
                                //创建成功后 第一时间 添加附件数据
                                attachMents.ForEach(attach => attach.MainId = result);
                                if (QuestionBLL.Instance.AddAttachMent(attachMents, Tran))
                                {
                                    //处理标签
                                    //如果用户没有添加标签,则根据算法匹配
                                    if (tags == null || tags.Length == 0)
                                    {
                                        List <string> newTags = new List <string>();
                                        //获取目前所有标签
                                        var currentTags = DB.Tag.Where(a => a.IsDelete == 0).Select(a => new { tagId = a.TagId, name = a.TagName }).ToList();
                                        var fittler     = HtmlRegexHelper.ToText(HttpUtility.UrlDecode(body)) + HtmlRegexHelper.ToText(title);
                                        var segObj      = new JiebaSegmenter();
                                        var segs        = segObj.Cut(fittler, cutAll: true).GroupBy(a => a).Select(a => a.Key).ToList();
                                        foreach (var seg in segs)
                                        {
                                            var match = currentTags.FirstOrDefault(a => a.name == seg);
                                            if (match != null)
                                            {
                                                if (newTags.Count < 3)
                                                {
                                                    newTags.Add(match.tagId.ToString());
                                                }
                                            }
                                            if (newTags.Count == 3)
                                            {
                                                break;
                                            }
                                        }
                                        if (newTags.Count == 0)
                                        {
                                            //如果没有匹配到,则创建
                                            var tagName = WordSpliterHelper.GetKeyword(fittler, true);
                                            if (tagName.Length > 6)
                                            {
                                                tagName = tagName.Substring(0, 6);
                                            }
                                            Tag tag = new Tag()
                                            {
                                                CreateTime    = DateTime.Now,
                                                CreateUser    = UserID.ToString(),
                                                TagBelongId   = 1038,
                                                TagName       = tagName,
                                                TagCreateType = 3,
                                                IsDelete      = 0,
                                            };
                                            var resultTag = TagBLL.Instance.Add(tag);
                                            newTags.Add(resultTag.ToString());
                                        }
                                        tags = newTags.ToArray();
                                    }

                                    if (MenuBelongTagBLL.Instance.HandleTags(result, CommentEnumType.Article, 1038, tags, Tran))
                                    {
                                        string uri = ConfigHelper.AppSettings("ArticleDetail").FormatWith(result);
                                        if (model.IsChecked == 1)
                                        {
                                            //通知发布用户 和 管理员
                                            noticeService.On_BBS_Article_Publish_Success_Notice(UserInfo, uri, title, 2);
                                            ri.Msg = "文章发表成功,您发布的文章成功触发系统审核机制,等待管理员审核成功后即可在页面里查看";
                                            ri.Url = "/Article";
                                        }
                                        else
                                        {
                                            ri.Msg = "文章发表成功";
                                            ri.Url = uri;
                                        }
                                        //异步通知关注者
                                        NoticeBLL.Instance.OnAdd_Notice_Liker(UserInfo.UserName, UserID, uri, model.Title, NoticeTypeEnum.Article_Add, GetDomainName);
                                        _scoreService.AddScoreOnPublish_BBS_Article(UserID, result, ScoreBeloneMainEnumType.Publish_Article, CoinSourceEnum.NewArticle);
                                        Commit();
                                        ri.Ok = true;
                                    }
                                    else
                                    {
                                        RollBack();
                                    }
                                }
                                else
                                {
                                    ri.Msg = "添加附件时失败,请重试";
                                    RollBack();
                                    //删除附件
                                    attachMents.ForEach(attach =>
                                    {
                                        UploadHelper.DeleteUpFile(attach.FilePath);
                                    });
                                }
                            }
                            else
                            {
                                RollBack();
                                ri.Msg = "文章发表失败";
                                //删除附件
                                attachMents.ForEach(attach =>
                                {
                                    UploadHelper.DeleteUpFile(attach.FilePath);
                                });
                            }
                        }
                        else
                        {
                            //删除附件
                            attachMents.ForEach(attach =>
                            {
                                UploadHelper.DeleteUpFile(attach.FilePath);
                            });
                        }
                    }
                    catch (Exception e)
                    {
                        ri.Msg = "新增文章失败";
                        RollBack();
                        //删除附件
                        attachMents.ForEach(attach =>
                        {
                            UploadHelper.DeleteUpFile(attach.FilePath);
                        });
                    }
                }
                else
                {
                    ri.Msg = "文章内容不能为空";
                }
            }
            else
            {
                ri.Msg = "文章标题不能为空";
            }
            return(Result(ri));
        }
        public ActionResult Publish(Product model)
        {
            ResultInfo ri = UpLoadImg("ProductPic", "/Content/Job/CP", beforeSaveFile: (save, resultinfo) =>
            {
                try
                {
                    BeginTran();
                    //判断VIP分是否足够
                    int publishScore = Convert.ToInt32(ConfigHelper.AppSettings("PUBLISH_PRODUCT"));
                    int type         = 2;
                    if (UserExtBLL.Instance.HasEnoughCoin(type, publishScore, UserID))
                    {
                        //扣除相应积分
                        bool logOk = UserExtBLL.Instance.SubScore(UserID, publishScore, type, Tran);
                        if (logOk)
                        {
                            if (ScoreCoinLogBLL.Instance.Log(-publishScore, type, CoinSourceEnum.PublishProduct, UserID, UserInfo.UserName, Tran))
                            {
                                resultinfo = save();
                                if (resultinfo.Ok)
                                {
                                    model.CreateTime = DateTime.Now;
                                    model.CreateUser = UserID.ToString();
                                    model.IsDelete   = 0;
                                    model.PLogo      = UserInfo.HeadUrl;
                                    model.ProductPic = resultinfo.Url;
                                    model.IsTop      = 0;
                                    model.IsJinghua  = 0;
                                    model.IsRemen    = 0;
                                    model.PVCount    = 0;
                                    model.UpdateTime = DateTime.Now;
                                    model.UpdateUser = UserID.ToString();
                                    model.ValidTime  = DateTime.Now.AddDays(GetRequest <int>("deadTime", 30));

                                    int result = ProductBLL.Instance.Add(model, Tran);

                                    if (result > 0)
                                    {
                                        var uri        = ConfigHelper.AppSettings("ProductDetail").FormatWith(result);
                                        resultinfo.Url = uri;
                                        resultinfo.Ok  = true;
                                        Commit();

                                        //通知作者
                                        NoticeBLL.Instance.OnPayPublish_Notice_Author(UserID, DateTime.Now, GetDomainName + uri, model.PTitle, 20, publishScore.ToString(), NoticeTypeEnum.Product_Pay_Publish);
                                        //通知关注作者的用户
                                        NoticeBLL.Instance.OnAdd_Notice_Liker(UserInfo.UserName, UserID, uri, model.PTitle, NoticeTypeEnum.Product_Add, GetDomainName);
                                    }
                                    else
                                    {
                                        RollBack();
                                        resultinfo.Msg = "发布失败";
                                    }
                                }
                            }
                            else
                            {
                                RollBack();
                                resultinfo.Msg = "发布失败";
                            }
                        }
                        else
                        {
                            RollBack();
                            resultinfo.Msg = "发布失败";
                        }
                    }
                    else
                    {
                        resultinfo.Msg = "VIP分不足,请去个人中心充值";
                    }
                }
                catch
                {
                    resultinfo.Msg = "发布异常 ";
                    RollBack();
                    UploadHelper.DeleteUpFile(resultinfo.Url);
                }
            });

            return(Result(ri));
        }
        public ActionResult Publish(ZhaoPin model, int deadTime, bool hasPic)
        {
            ResultInfo resultinfo = UpLoadImg("JobPic", "/Content/Job/ZP", beforeSaveFile: (save, ri) =>
            {
                try
                {
                    BeginTran();
                    //判断VIP分是否足够
                    int publishScore = Convert.ToInt32(ConfigHelper.AppSettings("PUBLISH_ZHAOPIN"));
                    int type         = 2;
                    if (UserExtBLL.Instance.HasEnoughCoin(type, publishScore, UserID))
                    {
                        //扣除相应积分
                        if (UserExtBLL.Instance.SubScore(UserID, publishScore, type, Tran))
                        {
                            //记录流水
                            if (ScoreCoinLogBLL.Instance.Log(-publishScore, type, CoinSourceEnum.PublishProduct, UserID, UserInfo.UserName, Tran))
                            {
                                if (hasPic)
                                {
                                    ri = save();
                                }

                                if (model.WorkeType == 1)
                                {
                                    model.WorkTime = null;
                                }

                                model.ValidTime  = DateTime.Now.AddDays(deadTime);
                                model.UpdateTime = DateTime.Now;
                                model.UpdateUser = UserID.ToString();
                                model.CreateTime = DateTime.Now;
                                model.Publisher  = UserID.ToString();
                                model.IsDelete   = 0;
                                model.CLogo      = UserInfo.HeadUrl;
                                model.JobPic     = ri?.Url;
                                model.IsTop      = 0;
                                model.IsJinghua  = 0;
                                model.IsRemen    = 0;
                                model.PVCount    = 0;

                                //创建招聘信息
                                int result = ZhaoPinBLL.Instance.Add(model, Tran);

                                if (result > 0)
                                {
                                    string uri = ConfigHelper.AppSettings("ZhaoPinDetail").FormatWith(result);
                                    ri.Url     = uri;
                                    ri.Ok      = true;
                                    Commit();

                                    //通知作者
                                    NoticeBLL.Instance.OnPayPublish_Notice_Author(UserID, DateTime.Now, GetDomainName + uri, model.Gangwei, 20, publishScore.ToString(), NoticeTypeEnum.ZhaoPin_Pay_Publish);
                                    //通知关注作者的用户
                                    NoticeBLL.Instance.OnAdd_Notice_Liker(UserInfo.UserName, UserID, uri, model.Gangwei, NoticeTypeEnum.ZhaoPin_Add, GetDomainName);
                                }
                                else
                                {
                                    ri.Msg = "发布失败";
                                    RollBack();
                                    UploadHelper.DeleteUpFile(ri.Url);
                                }
                            }
                            else
                            {
                                RollBack();
                                ri.Msg = "发布失败";
                            }
                        }
                        else
                        {
                            RollBack();
                            ri.Msg = "发布失败";
                        }
                    }
                    else
                    {
                        ri.Msg = "VIP分不足,请去个人中心充值";
                    }
                }
                catch
                {
                    ri.Msg = "发布异常 ";
                    RollBack();
                    UploadHelper.DeleteUpFile(ri.Url);
                }
            }, isNeedFile: hasPic);

            return(Result(resultinfo));
        }
        public ActionResult Edit(ZhaoPin model, int deadTime)
        {
            ResultInfo ri = new ResultInfo();

            if (ModelState.IsValid)
            {
                ZhaoPin _model = ZhaoPinBLL.Instance.GetModel(model.ZhaoPinID);
                if (_model == null)
                {
                    ri.Msg = "该求职信息已被删除";
                }
                else
                {
                    Action <string> action = (imagePath) =>
                    {
                        _model.CName       = model.CName;
                        _model.CPeople     = model.CPeople;
                        _model.Gangwei     = model.Gangwei;
                        _model.Money       = model.Money;
                        _model.Study       = model.Study;
                        _model.WorkHistory = model.WorkHistory;
                        _model.WorkPlace   = model.WorkPlace;
                        _model.Contact     = model.Contact;
                        _model.CDesc       = model.CDesc;
                        _model.JobRequire  = model.JobRequire;
                        _model.JobPic      = imagePath;

                        _model.BelongJobTrade = model.BelongJobTrade;
                        _model.BelongJob      = model.BelongJob;
                        _model.WorkeType      = model.WorkeType;
                        _model.WorkTime       = model.WorkTime;
                        _model.NeedCount      = model.NeedCount;
                        _model.JobFuLi        = model.JobFuLi;

                        _model.ValidTime  = DateTime.Now.AddDays(deadTime);
                        _model.UpdateTime = DateTime.Now;
                        if (_model.WorkeType == 1)
                        {
                            _model.WorkTime = null;
                        }

                        ri = ZhaoPinBLL.Instance.Update(_model);
                        if (ri.Ok)
                        {
                            ri.Url = ConfigHelper.AppSettings("ZhaoPinDetail").FormatWith(_model.ZhaoPinID);
                        }
                    };
                    //是否修改上传照片
                    if (GetRequest <bool>("ischange"))
                    {
                        string oldImagePath = _model.JobPic;
                        ri = UpLoadImg("JobPic", "/Content/Job/ZP");
                        if (ri.Ok)
                        {
                            action(ri.Url);
                            UploadHelper.DeleteUpFile(oldImagePath);
                        }
                    }
                    else
                    {
                        action(_model.JobPic);
                    }
                }
            }
            return(Result(ri));
        }