public void UploadSuccessReward(Guid fileId, int reqId) { DocService ds = Context.GetService <DocService>(); U_UserInfo u = base.GetUser(); DDocInfo doc = ds.DDocInfoBll.GetByFileId(fileId); //更新悬赏列表的加入文档数量 TReqDoc trdoc = ds.TReqDocBll.Get(reqId); trdoc.DocCount += 1; ds.TReqDocBll.Update(trdoc); //新增到加入列表 TJoinDoc jd = new TJoinDoc() { DocId = doc.DocId, TId = reqId, Title = doc.Title, UserId = u.UserId, IsWin = false }; ds.TJoinDocBll.Insert(jd); //转至我的投稿页面 AddSuccess("投稿成功"); Redirect("/my/MyContribute.do"); }
public void DoUpdateDoc([DataBind("DDocInfo")] DDocInfo doc) { try { UserService us = Context.GetService <UserService>(); DDocInfo oldDoc = us.DocInfoBll.GetByFileId(doc.FileId.Value); if (oldDoc != null) { oldDoc.Title = doc.Title; oldDoc.Description = doc.Description; oldDoc.Tags = doc.Tags; oldDoc.CateId = doc.CateId; oldDoc.Price = doc.Price; us.DocInfoBll.Update(oldDoc); //更新标签表 if (!string.IsNullOrEmpty(doc.Tags)) { string[] tags = doc.Tags.Split(' '); us.DTagBll.UpdateFromDoc(tags, oldDoc.DocId); } Redirect("/my/index.do"); return; } throw new Exception("查询文档为空"); } catch (Exception ex) { Utils.Log4Net.Error(ex); Flash["doc"] = doc; AddError("操作失败,系统错误"); RedirectToReferrer(); } }
public void DoUploadReplaceDoc(int originalId, HttpPostedFile fileData) { DocService ds = Context.GetService <DocService>(); DDocInfo originalDoc = ds.DDocInfoBll.Get(originalId); if (originalDoc != null) { //上传新文档 string ext = string.Empty; string savePath = Save(fileData, ref ext); DDocInfo newDoc = new DDocInfo() { UserId = ConfigHelper.AdminUserId, DocType = ext.ToLower(), FileId = Guid.NewGuid(), FileName = fileData.FileName.Replace("." + ext, ""), FileLength = fileData.ContentLength, CreateTime = DateTime.Now, PhysicalPath = savePath }; int newDocId = ds.DDocInfoBll.Insert(newDoc); //更新原来的文档 originalDoc.ReplaceDocId = newDocId; ds.DDocInfoBll.Update(originalDoc); } base.SuccessInfo(); RedirectToReferrer(); }
/// <summary> /// 设置中标 /// </summary> /// <param name="joinId"></param> public void SetZb(int joinId) { try { DocService ds = Context.GetService <DocService>(); UserService us = Context.GetService <UserService>(); U_UserInfo u = base.GetUser(); //投稿对象 TJoinDoc tj = ds.TJoinDocBll.Get(joinId); //是否已经中标了 if (tj.IsWin) { throw new TmmException("此投稿已经设置为中标"); } //悬赏对象 TReqDoc trDoc = ds.TReqDocBll.Get(tj.TId); //余额检测 decimal ye = us.MAccountBll.GetByUserId(u.UserId).Amount; if (ye < trDoc.Price) { throw new TmmException("您的余额不足,请先充值"); } //扣除需求方余额 us.MAccountBll.AccountExpend(u.UserId, trDoc.Price, Utils.TmmUtils.IPAddress(), trDoc.Title); //为投稿人增加余额 us.MAccountBll.AddAmount(tj.UserId, trDoc.Price, Utils.TmmUtils.IPAddress(), trDoc.Title); //更改原文档的owner DDocInfo doc = ds.DDocInfoBll.Get(tj.DocId); doc.UserId = u.UserId; doc.IsTaskDoc = false; ds.DDocInfoBll.Update(doc); PropertyBag["doc"] = doc; //更改投稿文档的状态 tj.IsWin = true; tj.WinTime = DateTime.Now; ds.TJoinDocBll.Update(tj); //发送通知 M_Message msg = new M_Message() { Mtype = (int)Model.Enums.MessageType.Inform, SenderId = ConfigHelper.AdminUserId, RecieverId = tj.UserId, Title = "您的投稿被选中", IsRead = false, CreateTime = DateTime.Now, Content = string.Format("您的投稿【{0}】被{1}设置中标,获得收入¥{2}", tj.Title, "<a href='/home/" + u.UserId + ".html' target='_blank'>" + u.TmmDispName + "</a>" , string.Format("{0:N2}", trDoc.Price)) }; us.MessageBll.Insert(msg); } catch (TmmException te) { AddError(te.Message); RedirectToReferrer(); } }
/// <summary> /// 插入数据 /// </summary> /// <param name="obj">对象</param> /// <returns>返回:该条数据的主键Id</returns> public int Insert(DDocInfo obj) { if (obj == null) { throw new ArgumentNullException("obj"); } String stmtId = "DDocInfo.Insert"; return(SqlMapper.Instance().QueryForObject <int>(stmtId, obj)); }
/// <summary> /// 更新数据 /// </summary> /// <param name="obj"></param> /// <returns>返回:ture 成功,false 失败</returns> public bool Update(DDocInfo obj) { if (obj == null) { throw new ArgumentNullException("obj"); } String stmtId = "DDocInfo.Update"; int result = SqlMapper.Instance().QueryForObject <int>(stmtId, obj); return(result > 0 ? true : false); }
public void EditDoc(int docId) { DocService ds = Context.GetService <DocService>(); DDocInfo doc = ds.DDocInfoBll.Get(docId); PropertyBag["doc"] = doc; SystemService ss = Context.GetService <SystemService>(); IList <S_Catalog> cates = ss.SCatalogBll.GetTopNode(); PropertyBag["cates"] = cates; }
public void RecommendDoc(int docId) { DocService ds = Context.GetService <DocService>(); DDocInfo doc = ds.DDocInfoBll.Get(docId); doc.IsRecommend = true; ds.DDocInfoBll.Update(doc); base.SuccessInfo(); RedirectToReferrer(); }
public void UploadSuccess(Guid fileId) { UserService us = Context.GetService <UserService>(); DDocInfo doc = us.DocInfoBll.GetByFileId(fileId); PropertyBag["doc"] = doc; SystemService ss = Context.GetService <SystemService>(); IList <S_Catalog> cates = ss.SCatalogBll.GetTopNode(); PropertyBag["cates"] = cates; }
/// <summary> /// 个人中心--编辑文档 /// </summary> /// <param name="docId"></param> public void EditDoc(int docId) { UserService us = Context.GetService <UserService>(); U_UserInfo u = base.GetUser(); DDocInfo doc = us.DocInfoBll.Get(docId, u.UserId); if (doc.IsAudit) { throw new TmmException("该文档已经发布,不能修改"); } PropertyBag["doc"] = doc; SystemService ss = Context.GetService <SystemService>(); IList <S_Catalog> cates = ss.SCatalogBll.GetTopNode(); PropertyBag["cates"] = cates; }
public void ReplaceDoc(int docId) { DocService ds = Context.GetService <DocService>(); DDocInfo originalDoc = ds.DDocInfoBll.Get(docId); DDocInfo replaceDoc = ds.DDocInfoBll.Get(originalDoc.ReplaceDocId.Value); originalDoc.ThumbnailUrl = replaceDoc.ThumbnailUrl; originalDoc.FlashUrl = replaceDoc.FlashUrl; originalDoc.PageCount = replaceDoc.PageCount; ds.DDocInfoBll.Update(originalDoc); //替换完成后删除文件 ds.DDocInfoBll.Delete(replaceDoc.DocId); //删除物理文件 File.Delete(replaceDoc.PhysicalPath); base.SuccessInfo(); RedirectToReferrer(); }
public void CancelAudit(int[] docIds) { DocService ds = Context.GetService <DocService>(); foreach (int docId in docIds) { DDocInfo doc = ds.DDocInfoBll.Get(docId); doc.IsAudit = false; ds.DDocInfoBll.Update(doc); //更新用户表的UploadCount UserService us = Context.GetService <UserService>(); int uc = ds.DDocInfoBll.GetCountByUser(doc.UserId); us.UserInfoBll.UpdateUploadCount(uc, doc.UserId); } base.SuccessInfo(); Redirect("/admin/doc/index.do"); }
public void SaveFile(HttpPostedFile fileData) { CancelLayout(); CancelView(); try { //保存文件 string ext = string.Empty; string savePath = Save(fileData, ref ext); UserService us = Context.GetService <UserService>(); U_UserInfo u = base.GetUser(); DDocInfo doc = new DDocInfo() { UserId = u.UserId, DocType = ext.ToLower(), FileId = Guid.NewGuid(), FileName = fileData.FileName.Replace("." + ext, ""), FileLength = fileData.ContentLength, CreateTime = DateTime.Now, PhysicalPath = savePath }; if (ConfigHelper.NotConvertDocTypes.Contains(ext.ToLower())) { doc.Wwk = 1; doc.Wwk2 = 1; doc.Txt = 1; } us.DocInfoBll.Insert(doc); Response.StatusCode = 200; Response.Write("{code:1,msg:'" + doc.FileId.Value.ToString() + "'}"); } catch (TmmException te) { Response.StatusCode = 200; Response.Write("{code:0,msg:'" + te.Message + "'}"); } catch (Exception ex) { Utils.Log4Net.Error("上传文档出错:" + ex.Message); Response.StatusCode = 500; Response.Write("{code:-1,msg:'" + ex.Message + "'}"); } }
/// <summary> /// 充值 /// </summary> public void DoCharge(string returnUrl, decimal total, int docId) { PropertyBag["cur_page_account"] = true; PropertyBag["returnUrl"] = returnUrl; PropertyBag["docId"] = docId; OrderService os = Context.GetService <OrderService>(); DDocInfo doc = os.DDocInfoBll.Get(docId); U_UserInfo logonUser = base.GetUser(); //os.TOrderBll.SaveOrder(order); //PropertyBag["order"] = order; PropertyBag["doc"] = doc; PropertyBag["acc"] = os.MAccountBll.GetByUserId(logonUser.UserId); PropertyBag["chargeRange"] = ChargeRange(total); PropertyBag["total"] = total; }
public void DeleteDoc(int[] docIds, string redirectUrl) { DocService ds = Context.GetService <DocService>(); UserService us = Context.GetService <UserService>(); foreach (int docId in docIds) { DDocInfo doc = ds.DDocInfoBll.Get(docId); U_UserInfo u = us.UserInfoBll.Get(doc.UserId); if (doc.IsAudit) { u.UploadCount -= 1; us.UserInfoBll.Update(u); } ds.DDocInfoBll.Delete(docId); } Utils.Log4Net.Error("Refer : " + Context.UrlReferrer); base.SuccessInfo(); RedirectToReferrer2(redirectUrl); }
/// <summary> /// 发布文档 from 投稿 /// </summary> /// <param name="joinId"></param> public void PublishContribute(int joinId) { try { DocService ds = Context.GetService <DocService>(); UserService us = Context.GetService <UserService>(); U_UserInfo u = base.GetUser(); //投稿对象 TJoinDoc tj = ds.TJoinDocBll.Get(joinId); if (tj.UserId != u.UserId) { throw new TmmException("操作失败,您不是该投稿的所有者"); } if (tj.IsWin) { throw new TmmException("操作失败,该投稿已中标"); } //发布文档 DDocInfo doc = ds.DDocInfoBll.Get(tj.DocId); doc.IsAudit = false; doc.IsTaskDoc = false; ds.DDocInfoBll.Update(doc); //删除投稿记录 ds.TJoinDocBll.Delete(joinId); //更新悬赏的投稿数 TReqDoc trDoc = ds.TReqDocBll.Get(tj.TId); trDoc.DocCount -= 1; ds.TReqDocBll.Update(trDoc); Redirect("EditDoc.do?docId=" + doc.DocId.ToString()); return; } catch (TmmException te) { AddError(te.Message); } RedirectToReferrer(); }
/// <summary> /// 支付成功的后续事件 /// </summary> public void ExecAfterPaid() { OrderService os = new OrderService(); os.Initialize(); U_UserInfo u = os.UserInfoBll.Get(this.UserId); TOrder o = os.TOrderBll.GetOrderAndDetail(this.OrderId); //检测订单状态 CheckOrder(o, new OrderStatus[] { OrderStatus.NewOrder }, u); //更新订单状态 os.TOrderBll.UpdateState2Paid(o.OrderId, this.Status, this.PayWay, this.PayDetail); //加入到我的购买 DDocInfo buyDoc = os.DDocInfoBll.Get(o.OrderDetails[0].DocId); if (buyDoc != null) { MPurchase mp = new MPurchase() { DocId = buyDoc.DocId, Price = buyDoc.Price, PurchaseTime = DateTime.Now, UserId = this.UserId, Title = buyDoc.Title, Saler = buyDoc.UserId, DocType = buyDoc.DocType }; os.MPurchaseBll.Insert(mp); //给上传人返利 AddAmountForUploader(o.OrderId, buyDoc.UserId, o.Total, os, buyDoc.DocId, buyDoc.Title, this.UserId, this.PayWay); } if (!string.IsNullOrEmpty(this.GotoUrl)) { HttpContext.Current.Response.Redirect(GotoUrl); } }
public void CheckDown(int docId) { try { U_UserInfo logonUser = base.GetUser(); //是否登录 if (logonUser == null) { RenderText("{code:0,msg:''}"); return; } DocService ds = Context.GetService <DocService>(); AccountService accs = Context.GetService <AccountService>(); // DDocInfo doc = ds.DDocInfoBll.Get(docId); if (doc == null) { RenderText("{code:1,msg:''}"); return; } else { if (doc.UserId == logonUser.UserId) //是否自己的文档 { //输出下载URL RenderText("{code:3,msg:'" + Utils.TmmUtils.GetDocDownValKey(logonUser.UserId, docId, doc.FileId.Value.ToString()) + "'}"); return; } else { //是否已经购买 bool isPurchase = accs.MPurchaseBll.IsPurchase(logonUser.UserId, docId); if (isPurchase) { //输出下载URL RenderText("{code:3,msg:'" + Utils.TmmUtils.GetDocDownValKey(logonUser.UserId, docId, doc.FileId.Value.ToString()) + "'}"); return; } else { //判断文档价格 if (doc.Price <= 0) { int todayDownCount = ds.DownloadLogBll.GetDownCountToday(logonUser.UserId); if (todayDownCount >= ConfigHelper.FreeDownCount) { //超过免费下载文档次数 RenderText("{code:4,msg:''}"); } else { //输出下载URL RenderText("{code:3,msg:'" + Utils.TmmUtils.GetDocDownValKey(logonUser.UserId, docId, doc.FileId.Value.ToString()) + "'}"); } return; } else { //输出消息 RenderText("{code:2,msg:'" + string.Format("{0},{1}", docId, doc.Price) + "'}"); } } } } } catch (Exception ex) { Utils.Log4Net.Error(ex); RenderText("{code:-1,msg:''}"); } }
public void DoEditDoc([DataBind("DDocInfo")] DDocInfo doc, HttpPostedFile file) { try { //DocService us = Context.GetService<DocService>(); UserService us = Context.GetService <UserService>(); DDocInfo oldDoc = us.DocInfoBll.Get(doc.DocId); if (oldDoc != null) { //更新缩略图 if (file != null && !string.IsNullOrEmpty(file.FileName)) { string newThumbUrl = SaveNewDocThumbnail(file, oldDoc.ThumbnailUrl); if (!string.IsNullOrEmpty(newThumbUrl)) { oldDoc.ThumbnailUrl = newThumbUrl; } } else { oldDoc.ThumbnailUrl = doc.ThumbnailUrl; } oldDoc.Title = doc.Title; oldDoc.Description = doc.Description; oldDoc.Tags = doc.Tags; oldDoc.CateId = doc.CateId; oldDoc.Price = doc.Price; oldDoc.FlashUrl = doc.FlashUrl; us.DocInfoBll.Update(oldDoc); //更新标签表 if (!string.IsNullOrEmpty(oldDoc.Tags) && oldDoc.Tags != doc.Tags) { string[] tags = doc.Tags.Split(' '); us.DTagBll.UpdateFromDoc(tags, oldDoc.DocId); } //异步通知用户文档被管理员更新 M_Message msg = new M_Message() { Content = string.Format("您上传的文档“{0}”被管理员更新", doc.Title), CreateTime = DateTime.Now, IsRead = false, Mtype = (int)Model.Enums.MessageType.Inform, RecieverId = oldDoc.UserId, SenderId = Helper.ConfigHelper.AdminUserId, Title = string.Format("您上传的文档“{0}”被管理员更新", doc.Title) }; Common.AsynMessage am = new AsynMessage(msg); am.Send(); Redirect("/admin/doc/index.do"); return; } throw new Exception("查询文档为空"); } catch (Exception ex) { Utils.Log4Net.Error(ex); RedirectToReferrer(); } }
public void DoMydoc(string opType, string folderName, string docIds, int applyFolderId, int folderType) { try { UserService us = Context.GetService <UserService>(); U_UserInfo u = base.GetUser(); switch (opType.ToLower()) { #region 新增文件夹 case "addfolder": MCatalog mc = new MCatalog() { CateText = folderName, CatalogType = folderType, CreateTime = DateTime.Now, DocCount = 0, UserId = u.UserId }; us.MCatalogBll.Insert(mc); break; #endregion #region 除文件夹 case "deletefolder": MCatalog dmc = us.MCatalogBll.Get(applyFolderId, u.UserId); if (dmc != null) { us.MCatalogBll.Delete(dmc.CateId); us.DocInfoBll.UpdateUserCatalog(u.UserId, dmc.CateId); } else { throw new Exception("操作失败"); } break; #endregion #region 重命名文件夹 case "updatefolder": MCatalog dmc2 = us.MCatalogBll.Get(applyFolderId, u.UserId); if (dmc2 != null) { dmc2.CateText = folderName; us.MCatalogBll.Update(dmc2); } else { throw new Exception("操作失败"); } break; #endregion #region 多选删除 case "deleteall": string[] strDocIds = docIds.Split(','); strDocIds.ToList().ForEach(s => { DDocInfo d = us.DocInfoBll.Get(int.Parse(s), u.UserId); if (d != null) { us.DocInfoBll.Delete(d.DocId); if (d.UserCateId != 0) { //文件夹文档数量减一 MCatalog dsmc = us.MCatalogBll.Get(d.UserCateId); dsmc.DocCount -= 1; us.MCatalogBll.Update(dsmc); } } else { throw new Exception("可能删除了不是自己的文档"); } }); break; #endregion #region 移动到文件夹 case "moveall": string[] strDocIds2 = docIds.Split(','); strDocIds2.ToList().ForEach(s => { us.DocInfoBll.MoveFolder(int.Parse(s), applyFolderId); }); break; #endregion #region 单个删除 case "deletesingle": string[] strDocIds3 = docIds.Split(','); strDocIds3.ToList().ForEach(s => { DDocInfo d = us.DocInfoBll.Get(int.Parse(s), u.UserId); if (d != null) { us.DocInfoBll.Delete(d.DocId); if (d.UserCateId != 0) { //文件夹文档数量减一 MCatalog dsmc = us.MCatalogBll.Get(d.UserCateId); dsmc.DocCount -= 1; us.MCatalogBll.Update(dsmc); } } else { throw new Exception("可能删除了不是自己的文档"); } }); break; #endregion #region 移动到收藏夹 case "moveallfav": string[] strDocIds4 = docIds.Split(','); strDocIds4.ToList().ForEach(s => { us.MFavoriteBll.MoveFolder(int.Parse(s), applyFolderId); }); break; #endregion #region 除收藏 case "deleteallfav": string[] strDocIds5 = docIds.Split(','); strDocIds5.ToList().ForEach(s => { us.MFavoriteBll.Delete(int.Parse(s)); }); break; #endregion } AddSuccess("操作成功"); } catch (Exception ex) { Utils.Log4Net.Error(ex); AddError("操作失败"); } RedirectToReferrer(); }
public void Download(int docId) { CancelLayout(); CancelView(); try { DocService ds = Context.GetService <DocService>(); DDocInfo doc = ds.DDocInfoBll.Get(docId); FileStream myFile = null; BinaryReader br = null; try { myFile = new FileStream(doc.PhysicalPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); br = new BinaryReader(myFile); Context.Response.AppendHeader("Accept-Ranges", "bytes"); HttpContext.Current.Response.Buffer = false; //Response.Buffer = false; Int64 fileLength = myFile.Length; Int64 startBytes = 0; Double pack = 10240; //10K bytes int dlSpeed = 512000; //下载速度 Int32 sleep = (Int32)Math.Floor(1000 * pack / dlSpeed) + 1; HttpContext.Current.Response.AddHeader("Content-Length", (fileLength - startBytes).ToString()); HttpContext.Current.Response.AddHeader("Connection", "Keep-Alive"); HttpContext.Current.Response.ContentType = "application/octet-stream"; HttpContext.Current.Response.AddHeader( "Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(doc.FileName, System.Text.Encoding.UTF8) + "." + doc.DocType ); br.BaseStream.Seek(startBytes, SeekOrigin.Begin); Int32 maxCount = (Int32)Math.Floor((fileLength - startBytes) / pack) + 1; for (Int32 i = 0; i < maxCount; i++) { if (Response.IsClientConnected) { Response.BinaryWrite(br.ReadBytes(Convert.ToInt32(pack))); System.Threading.Thread.Sleep(sleep); } else { break; } } } catch (Exception ex) { Utils.Log4Net.Error("admin file DownloadFile " + ex.ToString()); //DoAlert("异常错误 03"); } finally { if (br != null) { br.Close(); } if (myFile != null) { myFile.Close(); } } } catch (Exception ex) { Utils.Log4Net.Error(ex); } }
public void GotoPay(string PayWay, decimal total, string pname, int docId, int chargeType) { OrderService os = Context.GetService <OrderService>(); AccountService accs = Context.GetService <AccountService>(); U_UserInfo logonUser = base.GetUser(); decimal orderId = Utils.TmmUtils.GenOrderId(); DDocInfo doc = new DDocInfo(); TOrder order = new TOrder(); TOrderDetail detail = new TOrderDetail(); int orderType = 0; //订单类型 if (chargeType == 1) { doc = os.DDocInfoBll.Get(docId); orderType = (int)OrderType.DownDocOrder; } else if (chargeType == 0) { //如果是直接充值,这里虚拟一个doc对象,来作为订单的商品 doc = new DDocInfo() { DocId = -1, Title = "直接充值:" + total.ToString(), Price = total }; orderType = (int)OrderType.DirectCharge; } detail = new TOrderDetail() { DocId = doc.DocId, DocTitle = doc.Title, GoodsCount = 1, Price = doc.Price, OrderId = orderId }; order = new TOrder() { OrderType = orderType, OrderId = orderId, UserId = logonUser.UserId, Email = logonUser.Email, Total = detail.Price * detail.GoodsCount, Ip = Context.Request.UserHostAddress, Status = (int)OrderStatus.NewOrder, CreateTime = DateTime.Now, PayWay = Helper.FormatHelper.GetPayWay(PayWay), OrderDetails = new List <TOrderDetail>() { detail } }; os.TOrderBll.SaveOrder(order); TOrder o = os.TOrderBll.Get(orderId); decimal amount = 0;//除扣除账户余额外还需要支付金额 amount = total; //if (total > minfo.Amount) //{ // amount = total - minfo.Amount; //} //else { // //账户支付 //} #region 转至支付接口 if (PayWay.ToLower() == "tenpay") { TenPay pay = new TenPay(); pay.UserId = logonUser.UserId; pay.Send(orderId.ToString(), amount.ToString(), pname); } if (PayWay.ToLower() == "chinabank") { ChinaBankPay pay = new ChinaBankPay(); pay.Send(orderId.ToString(), amount.ToString(), pname); // Response.Write("ChinaBank"); } if (PayWay.ToLower() == "alipay") { AliPay pay = new AliPay(); pay.Send(orderId.ToString(), amount.ToString(), pname, logonUser.UserId); // Response.Write("ChinaBank"); } if (PayWay.ToLower() == "useraccount") { MAccount minfo = accs.MAccountBll.GetByUserId(logonUser.UserId); //账户 if (o.Total <= minfo.Amount && (o.Status == (int)OrderStatus.NewOrder)) { //ms.MAccount.AccountExpend(o.OrderId); ////ms.MOrder.UpdateOrder2Paid(o.OrderId, 0, "账户支付", (int)Models.MOrderStateInfo.己付款); //Web.Common.OrderCallBack oCallBack = new MamShare.Mall.Web.Common.OrderCallBack( // o.UserId, o.OrderId, 0, (int)Models.MOrderStateInfo.己付款, "账户支付"); //oCallBack.Update2Paid(); //Hashtable p = new Hashtable(); //p.Add("OrderId", o.OrderId); //RedirectToAction("payok.do", p); os.MAccountBll.AccountExpend(o.OrderId, Utils.TmmUtils.IPAddress()); //账户花销 Common.OrderCallBack oCallBack = new TMM.Core.Common.OrderCallBack(); oCallBack.UserId = o.UserId; oCallBack.OrderId = o.OrderId; oCallBack.PayWay = 0; oCallBack.Status = (int)OrderStatus.IsPaied; oCallBack.PayDetail = "账户支付"; oCallBack.GotoUrl = "/my/purchase.do"; oCallBack.ExecAfterPaid(); } else { Redirect("NetPay.do?orderid=" + o.OrderId); } } #endregion RenderView("pay"); }
public void DownloadDoc(int docId, string valkey) { CancelLayout(); CancelView(); try { DocService ds = Context.GetService <DocService>(); U_UserInfo logonUser = base.GetUser(); DDocInfo doc = ds.DDocInfoBll.Get(docId); FileStream myFile = null; BinaryReader br = null; try { #region 载文档前需要经过一系列的权限判断 #endregion myFile = new FileStream(doc.PhysicalPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite); br = new BinaryReader(myFile); Context.Response.AppendHeader("Accept-Ranges", "bytes"); HttpContext.Current.Response.Buffer = false; //Response.Buffer = false; Int64 fileLength = myFile.Length; Int64 startBytes = 0; Double pack = 10240; //10K bytes int dlSpeed = 512000; //下载速度 Int32 sleep = (Int32)Math.Floor(1000 * pack / dlSpeed) + 1; //if (Request.Headers["Range"] != null) //{ // Response.StatusCode = 206; // String[] range = Request.Headers["Range"].Split(new Char[] { '=', '-' }); // startBytes = ConvertUtility.ToInt64(range[1]); //} HttpContext.Current.Response.AddHeader("Content-Length", (fileLength - startBytes).ToString()); HttpContext.Current.Response.AddHeader("Connection", "Keep-Alive"); HttpContext.Current.Response.ContentType = "application/octet-stream"; HttpContext.Current.Response.AddHeader( "Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(doc.FileName, System.Text.Encoding.UTF8) + "." + doc.DocType ); br.BaseStream.Seek(startBytes, SeekOrigin.Begin); Int32 maxCount = (Int32)Math.Floor((fileLength - startBytes) / pack) + 1; for (Int32 i = 0; i < maxCount; i++) { if (Response.IsClientConnected) { Response.BinaryWrite(br.ReadBytes(Convert.ToInt32(pack))); System.Threading.Thread.Sleep(sleep); } else { break; } } //下载成功,写入一条下载日志 if (doc.Price == 0 && doc.UserId != logonUser.UserId) { //先判断是否已经写入过下载日志了 bool isExistLog = ds.DownloadLogBll.IsExistDownLog(logonUser.UserId, doc.DocId); if (!isExistLog) { DownloadLog downLog = new DownloadLog() { CreateTime = DateTime.Now, DocId = doc.DocId, UserId = logonUser.UserId }; ds.DownloadLogBll.Insert(downLog); } } } catch (Exception ex) { Utils.Log4Net.Error("file DownloadFile " + ex.ToString()); //DoAlert("异常错误 03"); } finally { if (br != null) { br.Close(); } if (myFile != null) { myFile.Close(); } } } catch (Exception ex) { Utils.Log4Net.Error(ex); } }
/// <summary> /// 更新数据 /// </summary> /// <param name="obj"></param> /// <returns>返回:ture 成功,false 失败</returns> public bool Update(DDocInfo obj) { return(dal.Update(obj)); }
/// <summary> /// 插入数据 /// </summary> /// <param name="obj">对象</param> /// <returns>返回:该条数据的主键Id</returns> public int Insert(DDocInfo obj) { return(dal.Insert(obj)); }
public void Default(int docId) { UserService us = Context.GetService <UserService>(); SystemService ss = Context.GetService <SystemService>(); DDocInfo doc = us.DocInfoBll.Get(docId); doc.Description = doc.Description.ReplaceEnterStr(); PropertyBag["doc"] = doc; if (!doc.IsAudit && !doc.IsTaskDoc) { if (!(Context.UrlReferrer.IndexOf("/admin/doc/index.do") > -1)) //如果从管理页面过来,不抛异常 { throw new Common.TmmException("该文档不存在"); } } try { //该用户其他文档 IList <DDocInfo> otherList = us.DocInfoBll.GetListByUser(doc.UserId, 0, 9, doc.DocId); PropertyBag["otherList"] = otherList; //文档分类 if (doc.CateId.HasValue) { S_Catalog c3 = ss.SCatalogBll.Get(doc.CateId.Value); S_Catalog c2 = null; S_Catalog c1 = null; if (c3 != null && c3.Pid.HasValue) { c2 = ss.SCatalogBll.Get(c3.Pid.Value); if (c2.Pid.HasValue) { c1 = ss.SCatalogBll.Get(c2.Pid.Value); } } StringBuilder sb = new StringBuilder(); if (c3 != null) { sb.Append(string.Format("<a href=\"/list-{1}-0-0-0-0-0.html\">{0}</a>", c3.CatalogName, c3.CatalogId)); if (c2 != null) { sb.Append(string.Format(" -- <a href=\"/list-{1}-0-0-0-0-0.html\">{0}</a>", c2.CatalogName, c2.CatalogId)); if (c1 != null) { sb.Append(string.Format(" -- <a href=\"/list-{1}-0-0-0-0-0.html\">{0}</a>", c1.CatalogName, c1.CatalogId)); } } } PropertyBag["catalog"] = sb.ToString(); } //标签 if (!string.IsNullOrEmpty(doc.Tags)) { string[] tags = doc.Tags.Split(' '); List <D_Tag> tagList = new List <D_Tag>(); tags.ToList().ForEach(s => { if (!string.IsNullOrEmpty(s.Trim())) { D_Tag dt = us.DTagBll.Get(s); if (dt != null) { tagList.Add(dt); } } }); PropertyBag["tagList"] = tagList; } //相关文档 IList <DDocInfo> recommandList = us.DocInfoBll.GetRelativeList(docId); if (recommandList == null) { PropertyBag["relativeDocs"] = us.DocInfoBll.GetRecommendList(0, 25); PropertyBag["recommend"] = true; } else { PropertyBag["relativeDocs"] = recommandList; } //浏览量 us.DocInfoBll.UpdateViewCount(docId); } catch (Exception ex) { Utils.Log4Net.Error(ex.Message + "\r\n" + ex.StackTrace); } }