📄 showdownloadurl.cs
字号:
namespace PowerEasy.WebSite
{
using PowerEasy.Accessories;
using PowerEasy.Common;
using PowerEasy.Components;
using PowerEasy.Contents;
using PowerEasy.Model.Accessories;
using PowerEasy.Web.UI;
using System;
using System.Data;
using System.IO;
using System.Web.UI.WebControls;
public class ShowDownloadUrl : DynamicPage
{
protected string downloadurl;
protected Panel PnlShowFlv;
protected Panel PnlShowMediaPlayer;
protected Panel PnlShowRealPlayer;
private void DownloadSoft(string newurl)
{
try
{
switch (Path.GetExtension(newurl).Replace(".", ""))
{
case "wmv":
case "mpg":
case "asf":
case "mp3":
case "mpeg":
case "avi":
this.ShowPannel("MediaPlayer");
return;
case "rm":
case "ra":
case "ram":
case "rmvb":
this.ShowPannel("RealPlayer");
return;
case "flv":
this.ShowPannel("Flv");
return;
}
base.Response.Redirect(this.downloadurl);
}
catch
{
throw new CustomException("下载地址文件格式不正确!");
}
}
protected void Page_Load(object sender, EventArgs e)
{
if (!this.Page.IsPostBack)
{
int urlid = BasePage.RequestInt32("urlid");
int id = BasePage.RequestInt32("id", 0);
int serverid = BasePage.RequestInt32("serverid", 0);
if (id <= 0)
{
DynamicPage.WriteErrMsg("错误的下载参数!", SiteConfig.SiteInfo.VirtualPath + "Default.aspx");
}
ChargeManage manage = new ChargeManage();
if (manage.CheckPermission())
{
manage.ExecuteContentCharge();
}
if (!string.IsNullOrEmpty(manage.ErrMsg))
{
DynamicPage.WriteErrMsg(manage.ErrMsg, SiteConfig.SiteInfo.VirtualPath + "Default.aspx");
}
string newurl = this.ParseDownLoadPath(urlid, id, serverid);
this.UpdateHits(id);
this.DownloadSoft(newurl);
}
}
private string ParseDownLoadPath(int urlid, int id, int serverid)
{
DataTable contentDataById = ContentManage.GetContentDataById(id);
if (contentDataById.Rows.Count <= 0)
{
DynamicPage.WriteErrMsg("此资源不存在!", SiteConfig.SiteInfo.VirtualPath + "Default.aspx");
}
string str = "";
DownServerInfo downServerById = DownServer.GetDownServerById(serverid);
string url = "";
if (contentDataById.Rows.Count > 0)
{
str = contentDataById.Rows[0]["DownloadUrl"].ToString();
int num = 0;
foreach (string str3 in str.Split(new string[] { "$$$" }, StringSplitOptions.RemoveEmptyEntries))
{
string[] strArray2 = str3.Split(new string[] { "|" }, StringSplitOptions.RemoveEmptyEntries);
if (num == urlid)
{
url = DataSecurity.HtmlDecode(strArray2[1]);
}
num++;
}
}
if (downServerById.IsNull)
{
this.downloadurl = Utility.ConvertAbsolutePath(SiteConfig.SiteInfo.VirtualPath + SiteConfig.SiteOption.UploadDir + "/", url);
return url;
}
string str4 = downServerById.ServerUrl.ToString();
if (!str4.StartsWith("http://", StringComparison.InvariantCultureIgnoreCase))
{
str4 = "http://" + str4;
}
if (!str4.EndsWith("/", StringComparison.InvariantCultureIgnoreCase))
{
str4 = str4 + "/";
}
if (url.StartsWith("/", StringComparison.InvariantCultureIgnoreCase) || url.Contains("://"))
{
this.downloadurl = url;
return url;
}
this.downloadurl = str4 + url;
this.downloadurl = this.downloadurl.Replace("//", "/");
return url;
}
private void ShowPannel(string showtype)
{
string str = showtype;
if (str != null)
{
if (!(str == "MediaPlayer"))
{
if (!(str == "RealPlayer"))
{
if (str == "Flv")
{
this.PnlShowMediaPlayer.Visible = false;
this.PnlShowRealPlayer.Visible = false;
this.PnlShowFlv.Visible = true;
}
return;
}
}
else
{
this.PnlShowMediaPlayer.Visible = true;
this.PnlShowRealPlayer.Visible = false;
this.PnlShowFlv.Visible = false;
return;
}
this.PnlShowMediaPlayer.Visible = false;
this.PnlShowRealPlayer.Visible = true;
this.PnlShowFlv.Visible = false;
}
}
private void UpdateHits(int id)
{
DataTable hitsDataById = ContentManage.GetHitsDataById(id);
if (hitsDataById.Rows.Count <= 0)
{
DynamicPage.WriteErrMsg("此资源不存在!", SiteConfig.SiteInfo.VirtualPath + "default.aspx");
}
DateTime time = DataConverter.CDate(hitsDataById.Rows[0]["LastHitTime"]);
int hits = DataConverter.CLng(hitsDataById.Rows[0]["Hits"]) + 1;
int dayhits = DataConverter.CLng(hitsDataById.Rows[0]["DayHits"]);
int weekhits = DataConverter.CLng(hitsDataById.Rows[0]["WeekHits"]);
int monthhits = DataConverter.CLng(hitsDataById.Rows[0]["MonthHits"]);
DateTime now = DateTime.Now;
DateTime time3 = DataConverter.CDate(now.ToShortDateString());
DateTime time4 = DataConverter.CDate(time.ToShortDateString());
if (DateTime.Compare(time4, time3) == 0)
{
dayhits = DataConverter.CLng(hitsDataById.Rows[0]["DayHits"]) + 1;
}
else
{
dayhits = 1;
}
DateTime time5 = DataConverter.CDate(now.AddDays(DataConverter.CDouble(-DataConverter.CLng(now.DayOfWeek))).ToShortDateString());
DateTime time6 = DataConverter.CDate(time5.AddDays(7.0).ToShortDateString());
if ((DateTime.Compare(time4, time5) >= 0) && (DateTime.Compare(time4, time6) <= 0))
{
weekhits = DataConverter.CLng(hitsDataById.Rows[0]["WeekHits"]) + 1;
}
else
{
weekhits = 1;
}
if ((string.Compare(time.Year.ToString(), now.Year.ToString()) == 0) && (string.Compare(time.Month.ToString(), now.Month.ToString()) == 0))
{
monthhits = DataConverter.CLng(hitsDataById.Rows[0]["MonthHits"]) + 1;
}
else
{
monthhits = 1;
}
ContentManage.UpdateHits(id, hits, dayhits, weekhits, monthhits, now);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -