Files
g.hnyhua.cn/Mtxfw.VipSite/Admin_Member_video.aspx.cs

306 lines
16 KiB
C#
Raw Permalink Normal View History

using System;
using System.Collections.Generic;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.IO;
using System.Data;
using TencentCloud.Common;
using TencentCloud.Common.Profile;
using TencentCloud.Vod.V20180717;
using TencentCloud.Vod.V20180717.Models;
namespace Mtxfw.VipSite
{
public partial class Admin_Member_video : Mtxfw.Utility.MemberBase
{
public Mtxfw.DAL.Article daoArt = new Mtxfw.DAL.Article();
public Mtxfw.Utility.Config config = new Mtxfw.Utility.Config("");
public int gtype = 0;
protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
string hostname = Request.Url.Host;
if (!IsPostBack)
{
if (Session["IFPassword"] == null)
{
Response.Redirect("/Member_IFPassword.aspx?Url=/Admin_Member_video.aspx");
}
if (IFStores != 1)
{
Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx");
}
if (MemberJS.IndexOf("视频管理") == -1)
{
Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx");
}
Data_Bind();
Page.Title = "视频管理 - " + GetWebName;
}
MyPager.PageChanged += delegate(object s, EventArgs ex)
{
Data_Bind();
};
}
protected void Data_Bind()
{
MyPager.PageSize = 50;
MyPager.RecordCount = daoArt.GetCount("gtype=" + gtype + " and ParentID=29");
if (MyPager.RecordCount == 0)
{
MyPager.Visible = false;
}
Mtxfw.Utility.Tools.ToBind(Repeater1, daoArt.GetPager(MyPager, "(Select Count(b.id) From Article b Where b.parentid=30 And b.senderid=a.id) as ACount,", "gtype=" + gtype + " and ParentID=29 Order by LinkID desc"));
}
protected void Delete_Click(object s, CommandEventArgs ex)
{
Int32 ID = int.Parse(ex.CommandName);
Mtxfw.Model.Article model = daoArt.GetModel(ID);
if (model != null)
{
if (model.Paths != "")
{
try
{
DataSet ds = new DAL.user_livefile().GetList("gtype=" + gtype + " and (ttype=1 or ttype=2) And liveid=" + model.id);
if (ds.Tables[0].Rows.Count > 0)
{
foreach (System.Data.DataRow Dr in ds.Tables[0].Rows)
{
int fid = Convert.ToInt32(Dr["id"]);
string file_id = Dr["file_id"].ToString();
// 必要步骤:
// 实例化一个认证对象,入参需要传入腾讯云账户密钥对 SecretIdSecretKey。
// 本示例采用从环境变量读取的方式,则需要在环境变量中先设置这两个值。
// 您也可以直接将密钥对写入代码中,但是注意不要复制、上传或分享代码,以免泄露密钥对危及您的财产安全。
Credential cred = new Credential
{
SecretId = config.AccessKeyId,
SecretKey = config.AccessKeySecret
};
// 实例化一个 client 选项,可选的,没有特殊需求可以跳过
ClientProfile clientProfile = new ClientProfile();
// 指定签名算法(默认为 HmacSHA256
clientProfile.SignMethod = ClientProfile.SIGN_SHA1;
// 非必要步骤
// 实例化一个客户端配置对象,可以指定超时时间等配置
HttpProfile httpProfile = new HttpProfile();
// SDK 默认使用 POST 方法。
// 如果您一定要使用 GET 方法可以在这里设置。GET 方法无法处理一些较大的请求。
httpProfile.ReqMethod = "POST";
// SDK 有默认的超时时间,非必要请不要进行调整。
// 如有需要请在代码中查阅以获取最新的默认值。
httpProfile.Timeout = 30; // 请求连接超时时间单位为秒默认值为60
// SDK 会自动指定域名。通常无需指定域名,但如果您访问的是金融区的服务,则必须手动指定域名。
// 例如云服务器的上海金融区域名cvm.ap-shanghai-fsi.tencentcloudapi.com
// 代理服务器,当您的环境下有代理服务器时设定
httpProfile.WebProxy = Environment.GetEnvironmentVariable("HTTPS_PROXY");
clientProfile.HttpProfile = httpProfile;
// 实例化要请求产品(以 CVM 为例)的 client 对象
// 第二个参数是地域信息,可以直接填写字符串 ap-guangzhou或者引用预设的常量clientProfile 是可选的
VodClient client = new VodClient(cred, "ap-beijing", clientProfile);
DeleteMediaRequest req = new DeleteMediaRequest();
req.FileId = file_id;
DeleteMediaResponse res = client.DeleteMediaSync(req);
// 输出 JSON 格式的字符串回包
Mtxfw.Utility.Common.WriteHtml("/weixin/TencentCloudDelete.txt", AbstractModel.ToJsonString(res) + "|" + res.RequestId);
new DAL.user_livefile().Delete(fid);
}
}
if (model.Author != "")
{
try
{
if (File.Exists(Server.MapPath(model.Author)))
{
File.Delete(Server.MapPath(model.Author));
}
}
catch
{
}
}
}
catch
{
}
}
Model.User_CZ_log logmodel = new Model.User_CZ_log();
logmodel.MemberId = Card;
logmodel.AddTime = DateTime.Now;
logmodel.IP = Mtxfw.Utility.Common.GetIP;
logmodel.Body = "删除视频,标题:" + model.Title + "";
logmodel.UType = 0;
logmodel.gtype = gtype;
new DAL.User_CZ_log().Add(logmodel);
}
daoArt.Delete(ID);
Response.Redirect(Request.Url.AbsoluteUri);
}
protected void Run_Click(object s, System.EventArgs e)
{
CheckBox Check = new CheckBox();
string strs = seclect_Drop.SelectedItem.Value;
foreach (RepeaterItem Item in Repeater1.Items)
{
//在行中查找到该单选框
Check = (CheckBox)Item.FindControl("checka");
int strID = int.Parse(Check.CssClass);
if (Check.Checked == true)
{
if (strs == "0")
{
Mtxfw.Model.Article model = daoArt.GetModel(strID);
if (model != null)
{
try
{
DataSet ds = new DAL.user_livefile().GetList("gtype=" + gtype + " and (ttype=1 or ttype=2) And liveid=" + model.id);
if (ds.Tables[0].Rows.Count > 0)
{
foreach (System.Data.DataRow Dr in ds.Tables[0].Rows)
{
int fid = Convert.ToInt32(Dr["id"]);
string file_id = Dr["file_id"].ToString();
// 必要步骤:
// 实例化一个认证对象,入参需要传入腾讯云账户密钥对 SecretIdSecretKey。
// 本示例采用从环境变量读取的方式,则需要在环境变量中先设置这两个值。
// 您也可以直接将密钥对写入代码中,但是注意不要复制、上传或分享代码,以免泄露密钥对危及您的财产安全。
Credential cred = new Credential
{
SecretId = config.AccessKeyId,
SecretKey = config.AccessKeySecret
};
// 实例化一个 client 选项,可选的,没有特殊需求可以跳过
ClientProfile clientProfile = new ClientProfile();
// 指定签名算法(默认为 HmacSHA256
clientProfile.SignMethod = ClientProfile.SIGN_SHA1;
// 非必要步骤
// 实例化一个客户端配置对象,可以指定超时时间等配置
HttpProfile httpProfile = new HttpProfile();
// SDK 默认使用 POST 方法。
// 如果您一定要使用 GET 方法可以在这里设置。GET 方法无法处理一些较大的请求。
httpProfile.ReqMethod = "POST";
// SDK 有默认的超时时间,非必要请不要进行调整。
// 如有需要请在代码中查阅以获取最新的默认值。
httpProfile.Timeout = 30; // 请求连接超时时间单位为秒默认值为60
// SDK 会自动指定域名。通常无需指定域名,但如果您访问的是金融区的服务,则必须手动指定域名。
// 例如云服务器的上海金融区域名cvm.ap-shanghai-fsi.tencentcloudapi.com
// 代理服务器,当您的环境下有代理服务器时设定
httpProfile.WebProxy = Environment.GetEnvironmentVariable("HTTPS_PROXY");
clientProfile.HttpProfile = httpProfile;
// 实例化要请求产品(以 CVM 为例)的 client 对象
// 第二个参数是地域信息,可以直接填写字符串 ap-guangzhou或者引用预设的常量clientProfile 是可选的
VodClient client = new VodClient(cred, "ap-beijing", clientProfile);
DeleteMediaRequest req = new DeleteMediaRequest();
req.FileId = file_id;
DeleteMediaResponse res = client.DeleteMediaSync(req);
// 输出 JSON 格式的字符串回包
Mtxfw.Utility.Common.WriteHtml("/weixin/TencentCloudDelete.txt", AbstractModel.ToJsonString(res) + "|" + res.RequestId);
new DAL.user_livefile().Delete(fid);
}
}
if (model.Author != "")
{
try
{
if (File.Exists(Server.MapPath(model.Author)))
{
File.Delete(Server.MapPath(model.Author));
}
}
catch
{
}
}
}
catch
{
}
Model.User_CZ_log logmodel = new Model.User_CZ_log();
logmodel.MemberId = Card;
logmodel.AddTime = DateTime.Now;
logmodel.IP = Mtxfw.Utility.Common.GetIP;
logmodel.Body = "删除视频,标题:" + model.Title + "";
logmodel.UType = 0;
logmodel.gtype = gtype;
new DAL.User_CZ_log().Add(logmodel);
daoArt.Delete(strID);
}
}
else if (strs == "1")
{
Mtxfw.Model.Article model = daoArt.GetModel(strID);
if (model != null)
{
Model.User_CZ_log logmodel = new Model.User_CZ_log();
logmodel.MemberId = Card;
logmodel.AddTime = DateTime.Now;
logmodel.IP = Mtxfw.Utility.Common.GetIP;
logmodel.Body = "隐藏视频,标题:" + model.Title + "";
logmodel.UType = 0;
logmodel.gtype = gtype;
new DAL.User_CZ_log().Add(logmodel);
//daoArt.UpdateuSeef();
daoArt.UpdateuSel("Seef", 1, strID);
}
}
else if (strs == "2")
{
Mtxfw.Model.Article model = daoArt.GetModel(strID);
if (model != null)
{
Model.User_CZ_log logmodel = new Model.User_CZ_log();
logmodel.MemberId = Card;
logmodel.AddTime = DateTime.Now;
logmodel.IP = Mtxfw.Utility.Common.GetIP;
logmodel.Body = "显示视频,标题:" + model.Title + "";
logmodel.UType = 0;
logmodel.gtype = gtype;
new DAL.User_CZ_log().Add(logmodel);
daoArt.UpdateuSel("Seef", 0, strID);
}
}
else if (strs == "3")
{
Mtxfw.Model.Article model = daoArt.GetModel(strID);
if (model != null)
{
TextBox LinkID = (TextBox)Item.FindControl("txtLinkID");
if (!System.Text.RegularExpressions.Regex.IsMatch(LinkID.Text, @"^-?\d+$"))
{
ClientScript.RegisterStartupScript(this.GetType(), "", "<script type='text/javascript'>alert('" + model.Title + "的排序ID填写错误');</script>");
}
else
{
daoArt.UpdateuSel("LinkID", Convert.ToInt32(LinkID.Text), strID);
}
}
}
}
}
Data_Bind();
}
}
}