<%@ Control Language="VB" Inherits="WanerSoft.Provider.BaseControl" AutoEventWireup="false" EnableViewState="false"%>
<%@ Import Namespace="System.IO" %>
<%@ Import Namespace="WanerSoft" %>
<%@ Import Namespace="WanerSoft.Common" %>
<%@ Import Namespace="WanerSoft.Provider" %>
<%@ Import Namespace="WanerSoft.Provider.Validate" %>
<%@ Import Namespace="WanerSoft.Model" %>
<%@ Import Namespace="WanerSoft.Data.Factory" %>
<%@ Register TagPrefix="Ws" TagName="Header" Src="../Common/Header.ascx" %>
<script runat="server">
Private M As New Ws_BookList
Private GuestCan As Boolean = False  '控制是否登陆才可下载
Private FileUrl As String
Protected Overrides Sub CreateChildControls()
  Response.Buffer = False
  Response.BufferOutput = False
  If GuestCan = False Then
      Cookies.UserCheck()  
  End If
  M = Ws.Instance.WebBookSelect(Common.Request.Sift("id", "int", 0))
  Header.Title=M.booktitle
  FileUrl = InfoSys.RootFolder + Common.Url.CreateEBookPath(M.id, InfoBook.BookUmdPathClass, InfoBook.BookUmdPath) + M.id.ToString + ".umd"
  DownFile()
End Sub
Private Sub DownFile()
  Dim StmD As FileInfo = New FileInfo(Common.Url.MapPath(FileUrl))
  If (StmD.Exists) Then
       If InfoBook.BookUmd Then
          If Datediff(DateInterval.Minute,StmD.LastWriteTime,M.bookupdatetime)>0 Then
               makes.Visible=True
          Else
               FactDown()
          End IF
	  Else
	      FactDown()
	  End IF
  Else
       If InfoBook.BookUmd Then
	       makes.Visible=True
	   Else
	       megs.Visible=True
	   End IF
  End If
End Sub
Private Sub FactDown()
     If GuestCan = False Then
          If Ws.Instance.WebUserLoadMoney(Cookies.GetSessions("ID")) < InfoBook.BookMoneyDownUmd Then
               Message.AlertAndClose("对不起，您的积分不够本次下载要求！")
               Message.WriteEnd()
          End If
          Ws.Instance.WebUserMoneyUpdate(Cookies.GetSessions("ID"), InfoBook.BookMoneyDownUmd, False)
    End If
    Response.Redirect(FileUrl)
End Sub
</script>
<Ws:Header id="Header" PageTitle="UMD电子书下载" StyleSheet="Book/DownUmd" Runat="Server" />
<asp:panel id="makes" CssClass="divm" Visible="False" runat="server">
<div id="imgs"><img src="/Skin/Default/Images/Runing.gif" width="32" height="32" /></div>
<div id="texts">正在生成UMD文件，请稍等....</div>
<%
Ws.Instance.BookUmdMake(M.id,InfoSys,InfoBook)
Message.AutoCloseWin(10)
%>
<script>window.location.href='Umd.<%=InfoSys.UrlReWriteExtName%>';</script>
</asp:panel>
<asp:panel id="megs" CssClass="divm" Visible="False" runat="server">
<div id="imgs"><img src="/Skin/Default/Images/2.gif" width="32" height="32" /></div>
<div id="texts">您所下载的文件暂时未能提供!</div>
<%Message.AutoCloseWin(10)%>
</asp:panel>
<%M=Nothing%>