using System; using System.Collections.Generic; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Text.RegularExpressions; using System.Globalization; using System.Text; using System.Security.Cryptography; using System.Data; namespace Mtxfw.VipSite { public partial class Admin_Member_dvideo_add : Mtxfw.Utility.MemberBase { public Mtxfw.Utility.Config config = new Mtxfw.Utility.Config(""); public Mtxfw.DAL.Article daoArt = new Mtxfw.DAL.Article(); Mtxfw.DAL.province daoPro = new Mtxfw.DAL.province(); public String strTitle = "",strBody = "", Signature = ""; protected String pid, cid, qid; public int gtype = 0; protected override void OnLoad(EventArgs e) { base.OnLoad(e); string hostname = Request.Url.Host; gtype = new DAL.host().GetId(hostname); txtUserId.Attributes.Add("placeholder", "请输入会员账号"); /*string secretId = config.AccessKeyId; long currentTimeStamp = Mtxfw.Utility.Common.CreatenTimestamp(DateTime.Now); long expireTime = Mtxfw.Utility.Common.CreatenTimestamp(DateTime.Now.AddHours(24)); string random = Mtxfw.Utility.Common.RandNum(6); long classId = 659337; string strkey = "secretId=" + secretId + "¤tTimeStamp=" + currentTimeStamp + "&expireTime=" + expireTime + "&random=" + random + "&classId=" + classId + "&storageRegion=ap-beijing"; byte[] bytesSign = hash_hmac_byte(strkey, config.AccessKeySecret); byte[] byteContent = System.Text.Encoding.Default.GetBytes(strkey); byte[] nCon = new byte[bytesSign.Length + byteContent.Length]; bytesSign.CopyTo(nCon, 0); byteContent.CopyTo(nCon, bytesSign.Length); Signature = Convert.ToBase64String(nCon);*/ if (!IsPostBack) { if (Session["IFPassword"] == null) { Response.Redirect("/Member_IFPassword.aspx?Url=/Admin_Member_dvideo.aspx"); } if (IFStores != 1) { Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx"); } if (MemberJS.IndexOf("视频管理") == -1) { Mtxfw.Utility.Tools.Message("您没有权限!", "/gl.aspx"); } } Data_Bind(); Btn_Insert.Click += delegate(object s, EventArgs ex) { bool b = true; Double xfjmoney = 0, tgjmoney = 0, jzjmoney = 0, gxzmoney = 0; int jlsecond=0; if (txtxfj.Text != "") { txtxfj.Text = txtxfj.Text.Trim(); if (!System.Text.RegularExpressions.Regex.IsMatch(txtxfj.Text, @"^-?([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$") && !System.Text.RegularExpressions.Regex.IsMatch(txtxfj.Text, @"^-?\d+$")) { b = false; ClientScript.RegisterStartupScript(this.GetType(), "", ""); } else { xfjmoney = Convert.ToDouble(txtxfj.Text); } } if (txttfll.Text != "") { txttfll.Text = txttfll.Text.Trim(); if (!System.Text.RegularExpressions.Regex.IsMatch(txttfll.Text, @"^-?([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$") && !System.Text.RegularExpressions.Regex.IsMatch(txttfll.Text, @"^-?\d+$")) { b = false; ClientScript.RegisterStartupScript(this.GetType(), "", ""); } else { tgjmoney = Convert.ToDouble(txttfll.Text); } } if (txtzxcs.Text != "") { txtzxcs.Text = txtzxcs.Text.Trim(); if (!System.Text.RegularExpressions.Regex.IsMatch(txtzxcs.Text, @"^-?\d+$")) { b = false; ClientScript.RegisterStartupScript(this.GetType(), "", ""); } else { jzjmoney = Convert.ToDouble(txtzxcs.Text); } } if (txtgxz.Text != "") { txtgxz.Text = txtgxz.Text.Trim(); if (!System.Text.RegularExpressions.Regex.IsMatch(txtgxz.Text, @"^-?([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$") && !System.Text.RegularExpressions.Regex.IsMatch(txtgxz.Text, @"^-?\d+$")) { b = false; ClientScript.RegisterStartupScript(this.GetType(), "", ""); } else { gxzmoney = Convert.ToDouble(txtgxz.Text); } } if (b) { if (txtsecond.Text != "") { txtsecond.Text = txtsecond.Text.Trim(); if (!System.Text.RegularExpressions.Regex.IsMatch(txtsecond.Text, @"^-?\d+$")) { b = false; ClientScript.RegisterStartupScript(this.GetType(), "", ""); } else { jlsecond = Convert.ToInt32(txtsecond.Text); } } } string strProvince = "", strCity = "", strCounty = ""; if (Request.Form["select_p"] != null) { strProvince = Request.Form["select_p"].ToString(); } if (Request.Form["select_c"] != null) { strCity = Request.Form["select_c"].ToString(); } if (Request.Form["select_q"] != null) { strCounty = Request.Form["select_q"].ToString(); } int senderid = 0; if (txtUserId.Text.Trim() != "") { string strzd = new DAL.user_info().Getzd("id", "UserName='" + txtUserId.Text.Trim() + "'").ToString(); if (strzd != "") { senderid = Convert.ToInt32(strzd); } } if (b) { Mtxfw.Model.Article model = new Mtxfw.Model.Article(); model.senderid = senderid;//所属商品ID model.receiverid = 0;//公司ID model.Title = Text_Title.Text; model.ParentID = 10; model.CategoryId = "0";//公司投放ID model.AddTime = DateTime.Now; model.Author = hiddenphoto.Value; model.Paths = hiddenvideo.Value; model.Paths2 = ""; model.Content = ""; model.Content2 = (ltype0.Checked ? hiddenlinks.Value : hiddenproducts.Value);//商品IDS model.KeyWords = strProvince;//权限区域省份 model.media_id = strCity;//权限区域城市 model.thumb_media_id = strCounty;//权限区域区县 model.wtype = 0; model.wtype2 = 0; string strzd = daoArt.Getzd("max(LinkID)", "ParentID=" + model.ParentID).ToString(); if (strzd != "") { model.LinkID = (Convert.ToInt32(strzd) + 1); } else { model.LinkID = 0; } model.Seef = 1; model.ltype = (ltype0.Checked ? 1 : 0); model.gtype = 0; model.id = daoArt.Add(model); model = daoArt.GetModel(model.id); Decimal latitude = (xcoo.Value != "" ? Convert.ToDecimal(xcoo.Value) : 0); Decimal longitude = (ycoo.Value != "" ? Convert.ToDecimal(ycoo.Value) : 0); model.jlsecond = jlsecond;//奖励秒数 model.xfjmoney = Convert.ToDouble(txtxfj.Text); model.tfllmoney = Convert.ToDouble(txttfll.Text); model.zscs = Convert.ToInt32(txtzxcs.Text); model.gxzmoney = (txtgxz.Text != "" ? Convert.ToDouble(txtgxz.Text) : 0); model.ltype = (ltype0.Checked ? 1 : 0); model.csday = Convert.ToInt32(txtdays.Text); model.latitude = latitude; model.longitude = longitude; if (model.Paths != "") { if (model.Paths.IndexOf("https://fv.pmhapp.cn/mdavideo/") != -1) { Qiniu.Util.Mac mac = new Qiniu.Util.Mac(config.qiniuAccessKey, config.qiniuSecretKey); //Qiniu.Storage.PutPolicy putPolicy = new Qiniu.Storage.PutPolicy(); //putPolicy.Scope = config.qiniuScope; //string upToken = Qiniu.Util.Auth.CreateUploadToken(mac, putPolicy.ToJsonString()); Qiniu.Storage.Config qnconfig = new Qiniu.Storage.Config(); // 设置上传区域 qnconfig.Zone = Qiniu.Storage.Zone.ZONE_CN_South; // 设置 http 或者 https 上传 qnconfig.UseHttps = true; qnconfig.UseCdnDomains = true; string Bucket = config.qiniuScope; // 文件名 string Key = model.Paths.Replace("https://fv.pmhapp.cn/", ""); bool force = false; // 队列名称,如果没有,请设置为null // 另请参阅https://qiniu.kf5.com/hc/kb/article/112978/ string pipeline = "default.sys"; // 接收处理结果通知的URL,另请参阅 string notifyUrl = config.webUrl + "/pay/qiniunotifyUrl.aspx"; // 要保存的目标空间 string dstBucket = config.qiniuScope; string dstKey = Key.Replace("mdavideo/", "mdadvideo/"); string saveAsUri = Qiniu.Util.Base64.UrlSafeBase64Encode(dstBucket + ":" + dstKey); // 需要执行的数据处理,例如视频转码 string fopM = "avthumb/mp4"; //示例: "avthumb/mp4"; // 使用管道'|'命令,将处理结果saveas另存 string fops = fopM + "|saveas/" + saveAsUri; // 这个示例单独使用了一个Settings类,其中包含AccessKey和SecretKey // 实际应用中,请自行设置您的AccessKey和SecretKey Qiniu.Storage.OperationManager ox = new Qiniu.Storage.OperationManager(mac, qnconfig); Qiniu.Storage.PfopResult result = ox.Pfop(Bucket, Key, fops, pipeline, notifyUrl, force); if (result.Code == 200) { model.thumb_media_id = result.PersistentId; } } } daoArt.Update(model); 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); if (Session["UploadFileIng"] != null) { string[] stra = Session["UploadFileIng"].ToString().Split(','); foreach (string str in stra) { if (str.Trim() != "") { if (model.Content.IndexOf(str.Trim()) == -1) { if (System.IO.File.Exists(Server.MapPath(str.Trim()))) { System.IO.File.Delete(Server.MapPath(str.Trim())); } } } } Session.Remove("UploadFileIng"); } if (Session["UploadFileIng0"] != null) { string[] stra = Session["UploadFileIng0"].ToString().Split(','); foreach (string str in stra) { if (str.Trim() != "") { if (model.Author != str.Trim()) { if (System.IO.File.Exists(Server.MapPath(str.Trim()))) { System.IO.File.Delete(Server.MapPath(str.Trim())); } } } } Session.Remove("UploadFileIng0"); } System.Collections.IDictionaryEnumerator CacheEnum = Cache.GetEnumerator(); while (CacheEnum.MoveNext()) { Cache.Remove(CacheEnum.Key.ToString()); } ClientScript.RegisterStartupScript(this.GetType(), "", ""); } }; Btn_Update.Click += delegate(object s, EventArgs ex) { bool b = true; Double xfjmoney = 0, tgjmoney = 0, jzjmoney = 0, gxzmoney = 0; int jlsecond=0; if (txtxfj.Text != "") { txtxfj.Text = txtxfj.Text.Trim(); if (!System.Text.RegularExpressions.Regex.IsMatch(txtxfj.Text, @"^-?([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$") && !System.Text.RegularExpressions.Regex.IsMatch(txtxfj.Text, @"^-?\d+$")) { b = false; ClientScript.RegisterStartupScript(this.GetType(), "", ""); } else { xfjmoney = Convert.ToDouble(txtxfj.Text); } } if (txttfll.Text != "") { txttfll.Text = txttfll.Text.Trim(); if (!System.Text.RegularExpressions.Regex.IsMatch(txttfll.Text, @"^-?([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$") && !System.Text.RegularExpressions.Regex.IsMatch(txttfll.Text, @"^-?\d+$")) { b = false; ClientScript.RegisterStartupScript(this.GetType(), "", ""); } else { tgjmoney = Convert.ToDouble(txttfll.Text); } } if (txtzxcs.Text != "") { txtzxcs.Text = txtzxcs.Text.Trim(); if (!System.Text.RegularExpressions.Regex.IsMatch(txtzxcs.Text, @"^-?\d+$")) { b = false; ClientScript.RegisterStartupScript(this.GetType(), "", ""); } else { jzjmoney = Convert.ToDouble(txtzxcs.Text); } } if (txtgxz.Text != "") { txtgxz.Text = txtgxz.Text.Trim(); if (!System.Text.RegularExpressions.Regex.IsMatch(txtgxz.Text, @"^-?([1-9]\d*\.\d*|0\.\d*[1-9]\d*|0?\.0+|0)$") && !System.Text.RegularExpressions.Regex.IsMatch(txtgxz.Text, @"^-?\d+$")) { b = false; ClientScript.RegisterStartupScript(this.GetType(), "", ""); } else { gxzmoney = Convert.ToDouble(txtgxz.Text); } } if (b) { if (txtsecond.Text != "") { txtsecond.Text = txtsecond.Text.Trim(); if (!System.Text.RegularExpressions.Regex.IsMatch(txtsecond.Text, @"^-?\d+$")) { b = false; ClientScript.RegisterStartupScript(this.GetType(), "", ""); } else { jlsecond = Convert.ToInt32(txtsecond.Text); } } } string strProvince = "", strCity = "", strCounty = ""; if (Request.Form["select_p"] != null) { strProvince = Request.Form["select_p"].ToString(); } if (Request.Form["select_c"] != null) { strCity = Request.Form["select_c"].ToString(); } if (Request.Form["select_q"] != null) { strCounty = Request.Form["select_q"].ToString(); } if (b) { int senderid = 0; if (txtUserId.Text.Trim() != "") { string strzd = new DAL.user_info().Getzd("id", "UserName='" + txtUserId.Text.Trim() + "'").ToString(); if (strzd != "") { senderid = Convert.ToInt32(strzd); } } Int32 ID = int.Parse(Request.QueryString["ID"]); Mtxfw.Model.Article model = daoArt.GetModel(ID); model.senderid = senderid; model.Title = Text_Title.Text; model.Author = hiddenphoto.Value; model.Paths = hiddenvideo.Value; model.Content2 = (ltype0.Checked ? hiddenlinks.Value : hiddenproducts.Value);//商品IDS model.KeyWords = strProvince;//权限区域省份 model.media_id = strCity;//权限区域城市 model.thumb_media_id = strCounty;//权限区域区县 Decimal latitude = (xcoo.Value != "" ? Convert.ToDecimal(xcoo.Value) : 0); Decimal longitude = (ycoo.Value != "" ? Convert.ToDecimal(ycoo.Value) : 0); model.jlsecond = jlsecond;//奖励秒数 model.xfjmoney = Convert.ToDouble(txtxfj.Text); model.tfllmoney = Convert.ToDouble(txttfll.Text); model.zscs = Convert.ToInt32(txtzxcs.Text); model.gxzmoney = (txtgxz.Text != "" ? Convert.ToDouble(txtgxz.Text) : 0); model.ltype = (ltype0.Checked ? 1 : 0); model.csday = Convert.ToInt32(txtdays.Text); model.latitude = latitude; model.longitude = longitude; if (model.Paths != "") { if (model.Paths.IndexOf("https://fv.pmhapp.cn/mdavideo/") != -1) { Qiniu.Util.Mac mac = new Qiniu.Util.Mac(config.qiniuAccessKey, config.qiniuSecretKey); //Qiniu.Storage.PutPolicy putPolicy = new Qiniu.Storage.PutPolicy(); //putPolicy.Scope = config.qiniuScope; //string upToken = Qiniu.Util.Auth.CreateUploadToken(mac, putPolicy.ToJsonString()); Qiniu.Storage.Config qnconfig = new Qiniu.Storage.Config(); // 设置上传区域 qnconfig.Zone = Qiniu.Storage.Zone.ZONE_CN_South; // 设置 http 或者 https 上传 qnconfig.UseHttps = true; qnconfig.UseCdnDomains = true; string Bucket = config.qiniuScope; // 文件名 string Key = model.Paths.Replace("https://fv.pmhapp.cn/", ""); bool force = false; // 队列名称,如果没有,请设置为null // 另请参阅https://qiniu.kf5.com/hc/kb/article/112978/ string pipeline = "default.sys"; // 接收处理结果通知的URL,另请参阅 string notifyUrl = config.webUrl + "/pay/qiniunotifyUrl.aspx"; // 要保存的目标空间 string dstBucket = config.qiniuScope; string dstKey = Key.Replace("mdavideo/", "mdadvideo/"); string saveAsUri = Qiniu.Util.Base64.UrlSafeBase64Encode(dstBucket + ":" + dstKey); // 需要执行的数据处理,例如视频转码 string fopM = "avthumb/mp4"; //示例: "avthumb/mp4"; // 使用管道'|'命令,将处理结果saveas另存 string fops = fopM + "|saveas/" + saveAsUri; // 这个示例单独使用了一个Settings类,其中包含AccessKey和SecretKey // 实际应用中,请自行设置您的AccessKey和SecretKey Qiniu.Storage.OperationManager ox = new Qiniu.Storage.OperationManager(mac, qnconfig); Qiniu.Storage.PfopResult result = ox.Pfop(Bucket, Key, fops, pipeline, notifyUrl, force); //Mtxfw.Utility.Common.WriteHtml("/weixin/Qiniu.txt", result.Code + "|" + result.PersistentId + "|" + result.Text); if (result.Code == 200) { model.thumb_media_id = result.PersistentId; } } } daoArt.Update(model); 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); if (Session["UploadFileIng"] != null) { string[] stra = Session["UploadFileIng"].ToString().Split(','); foreach (string str in stra) { if (str.Trim() != "") { if (model.Content.IndexOf(str.Trim()) == -1) { if (System.IO.File.Exists(Server.MapPath(str.Trim()))) { System.IO.File.Delete(Server.MapPath(str.Trim())); } } } } Session.Remove("UploadFileIng"); } if (Session["UploadFileIng0"] != null) { string[] stra = Session["UploadFileIng0"].ToString().Split(','); foreach (string str in stra) { if (str.Trim() != "") { if (model.Author != str.Trim()) { if (System.IO.File.Exists(Server.MapPath(str.Trim()))) { System.IO.File.Delete(Server.MapPath(str.Trim())); } } } } Session.Remove("UploadFileIng0"); } System.Collections.IDictionaryEnumerator CacheEnum = Cache.GetEnumerator(); while (CacheEnum.MoveNext()) { Cache.Remove(CacheEnum.Key.ToString()); } ClientScript.RegisterStartupScript(this.GetType(), "", ""); } }; } protected String GetProvince() { StringBuilder sb = new StringBuilder(); System.Data.DataSet Ds = daoPro.GetCacheList("", "1=1 Order by Id Asc", "Province"); System.Data.DataTable Dt = (Ds != null && Ds.Tables[0] != null) ? Ds.Tables[0] : null; foreach (System.Data.DataRow Dr in Dt.Rows) { sb.Append("\r\n"); } return sb.ToString(); } protected void Data_Bind() { if (!IsPostBack) { ltype.Attributes.Add("onclick", "onltype(0)"); ltype0.Attributes.Add("onclick", "onltype(1)"); if (Request.UrlReferrer != null) { Hidd_Url.Value = Request.UrlReferrer.ToString(); } else { Hidd_Url.Value = "Admin_Member_dvideo.aspx"; } } if (Request.QueryString["ID"] == null) { strTitle = "添加视频"; if (!IsPostBack) { Page.Title = strTitle + " - " + GetWebName; Btn_Update.Visible = false; } } else { strTitle = "更新视频"; if (!IsPostBack) { Page.Title = strTitle + " - " + GetWebName; Btn_Insert.Visible = false; } Mtxfw.Model.Article model = daoArt.GetModel(int.Parse(Request.QueryString["ID"])); if (model != null) { if (!IsPostBack) { Text_Title.Text = model.Title; hiddenvideo.Value = model.Paths; hiddenphoto.Value = model.Author; txtsecond.Text = model.jlsecond.ToString(); txtdays.Text = model.csday.ToString(); ycoo.Value = model.longitude.ToString(); xcoo.Value = model.latitude.ToString(); hiddenlinks.Value = model.Content2; txtxfj.Text = model.xfjmoney.ToString(); txttfll.Text = model.tfllmoney.ToString(); txtzxcs.Text = model.zscs.ToString(); txtgxz.Text = model.gxzmoney.ToString(); if (model.senderid > 0) { string strzd = new DAL.user_info().Getzd("UserName", "id=" + model.senderid + "").ToString(); if (strzd != "") { txtUserId.Text = strzd; } } if(model.ltype == 1) { ltype0.Checked = true; hiddenlinks.Value = model.Content2; } else { ltype.Checked = true; hiddenproducts.Value = model.Content2; } } strBody = model.Content; pid = model.KeyWords; cid = model.media_id; qid = model.thumb_media_id; } } } private byte[] hash_hmac_byte(string signatureString, string secretKey) { var enc = Encoding.UTF8; HMACSHA1 hmac = new HMACSHA1(enc.GetBytes(secretKey)); hmac.Initialize(); byte[] buffer = enc.GetBytes(signatureString); return hmac.ComputeHash(buffer); } } }