314 lines
9.9 KiB
C#
314 lines
9.9 KiB
C#
using System;
|
||
using System.Collections.Generic;
|
||
using System.IO;
|
||
using System.Linq;
|
||
using System.Web;
|
||
using System.Web.UI;
|
||
using System.Web.UI.WebControls;
|
||
using Telerik.Web.UI;
|
||
|
||
namespace VRS.Management
|
||
{
|
||
public partial class App_Add : BasePage
|
||
{
|
||
DataService.BLL.pro_app bll = new DataService.BLL.pro_app();
|
||
|
||
DataService.BLL.admin_log log = new DataService.BLL.admin_log();
|
||
protected override void Page_Load(object sender, EventArgs e)
|
||
{
|
||
base.Page_Load(sender, e);
|
||
if (!IsPostBack)
|
||
{
|
||
BindMajors(dp_major, "");
|
||
BindSoft(dp_soft, "");
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 绑定科目
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void dp_major_SelectedIndexChanged(object sender, DropDownListEventArgs e)
|
||
{
|
||
var value = dp_major.SelectedValue;
|
||
BindMajorSubject(value, dp_subject, "");
|
||
|
||
}
|
||
|
||
protected void btnSure_Click(object sender, EventArgs e)
|
||
{
|
||
|
||
if (string.IsNullOrEmpty(app_name.Text) || string.IsNullOrEmpty(dp_major.SelectedValue) || string.IsNullOrEmpty(dp_subject.SelectedValue) || string.IsNullOrEmpty(dp_soft.SelectedValue))
|
||
{
|
||
RadAjaxManager1.Alert("应用名称、业务场景分类、专业分类、终端类型不能为空!");
|
||
return;
|
||
}
|
||
if (string.IsNullOrEmpty(dp_type.SelectedValue))
|
||
{
|
||
RadAjaxManager1.Alert("应用类型不能为空!");
|
||
return;
|
||
}
|
||
|
||
/*
|
||
if (bll.GetRecordCount(string.Format(" login_name = '{0}' ", login_name.Text.Trim())) > 0)
|
||
{
|
||
RadAjaxManager1.Alert("账号禁止重复!");
|
||
return;
|
||
}
|
||
*/
|
||
|
||
var model = new DataService.Model.pro_app();
|
||
model.id = "app" + BasePage.GetId();
|
||
|
||
model.app_name = app_name.Text.Trim();
|
||
model.type = dp_type.SelectedValue;
|
||
|
||
model.soft_id = dp_soft.SelectedValue;
|
||
model.major_id = dp_major.SelectedValue;
|
||
model.subject_id = dp_subject.SelectedValue;
|
||
|
||
model.platform = platform.Text.Trim();
|
||
model.train_scene = train_scene.Text.Trim();
|
||
model.config_condition = config_condition.Text.Trim();
|
||
|
||
|
||
|
||
//`soft_dsc` longtext '软件介绍',
|
||
//`yw_dsc` longtext '业务介绍',
|
||
//`func_dsc` longtext '功能介绍',
|
||
|
||
model.is_hot = is_hot.SelectedValue;
|
||
model.online_time = dp_online_time.SelectedDate;
|
||
|
||
|
||
//`video_url` varchar(50) '视频介绍',
|
||
//model.video_url = video.Src;
|
||
//视频介绍
|
||
model.video_url = hid_url_video_js.Value;
|
||
|
||
//软件下载地址
|
||
model.app_url = hid_url.Value;
|
||
|
||
//封面截图
|
||
model.cover_pic_url = hid_url_pic_cover.Value;
|
||
|
||
var user = DataService.BLL.admin_user.load_login();
|
||
if (null != user)
|
||
{
|
||
model.user_id = user.user_id;
|
||
}
|
||
model.create_time = DateTime.Now;
|
||
|
||
if (bll.Add(model))
|
||
{
|
||
log.write_log("添加应用成功。" + "应用:" + model.app_name + ",ID:" + model.user_id);
|
||
RadAjaxManager1.ResponseScripts.Add("alert('添加成功!');CloseAndRebind();");
|
||
}
|
||
else
|
||
{
|
||
RadAjaxManager1.Alert("添加失败!");
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 添加视频介绍
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnUpload_Click(object sender, EventArgs e)
|
||
{
|
||
if (RadAsyncUpload1.UploadedFiles.Count < 1)
|
||
{
|
||
RadAjaxManager1.Alert("未选择视频文件!");
|
||
return;
|
||
}
|
||
|
||
var uploadFile = RadAsyncUpload1.UploadedFiles[0];
|
||
/*
|
||
//视频介绍
|
||
var upload_type = "1";// type.SelectedValue;
|
||
|
||
if (upload_type == "0") //图片
|
||
{
|
||
var arrray = Util.ConfigInfo.list_pic_type;
|
||
var extension = uploadFile.GetExtension();
|
||
if (!arrray.Contains(extension))
|
||
{
|
||
RadAjaxManager1.Alert("请上传图片!");
|
||
return;
|
||
}
|
||
}
|
||
else if (upload_type == "1") //视频,.mp4,.avi,.dat,.3gp,.mov,.rmvb
|
||
{
|
||
var arrray = Util.ConfigInfo.list_video_type;
|
||
var extension = uploadFile.GetExtension();
|
||
if (!arrray.Contains(extension))
|
||
{
|
||
RadAjaxManager1.Alert("请上传视频!");
|
||
return;
|
||
}
|
||
}
|
||
*/
|
||
var arrray = Util.ConfigInfo.list_video_type;
|
||
var extension = uploadFile.GetExtension();
|
||
if (!arrray.Contains(extension))
|
||
{
|
||
RadAjaxManager1.Alert("请上传视频!");
|
||
return;
|
||
}
|
||
|
||
if (BasePage.SaveFile(uploadFile, Context, out string filePath))
|
||
{
|
||
//imgTopic.ImageUrl = "~" + filePath;
|
||
/*
|
||
if (upload_type == "0")
|
||
{
|
||
td_pic.Visible = true;
|
||
td_video.Visible = false;
|
||
imgTopic.ImageUrl = "~" + filePath;
|
||
}
|
||
else
|
||
{
|
||
td_pic.Visible = false;
|
||
td_video.Visible = true;
|
||
video.Src = "~" + filePath;
|
||
}
|
||
*/
|
||
|
||
//video.Src = "~" + filePath;
|
||
hid_url_video_js.Value= "~" + filePath;
|
||
url_video_js.Text = "~" + filePath;
|
||
}
|
||
else
|
||
{
|
||
RadAjaxManager1.Alert("上传失败!");
|
||
}
|
||
}
|
||
|
||
/// <summary>
|
||
/// 移除视频介绍
|
||
/// </summary>
|
||
/// <param name="sender"></param>
|
||
/// <param name="e"></param>
|
||
protected void btnRemove_Click(object sender, EventArgs e)
|
||
{
|
||
if (!string.IsNullOrEmpty(hid_url_video_js.Value))
|
||
{
|
||
string path = Server.MapPath(hid_url_video_js.Value);
|
||
if (File.Exists(path))
|
||
{
|
||
File.SetAttributes(path, FileAttributes.Normal);
|
||
File.Delete(path);
|
||
}
|
||
hid_url_video_js.Value = "";
|
||
url_video_js.Text = "";
|
||
}
|
||
}
|
||
|
||
|
||
#region 软件下载、移除
|
||
|
||
protected void btnUpload_Click2(object sender, EventArgs e)
|
||
{
|
||
upload_click(RadAsyncUpload2);
|
||
}
|
||
|
||
public void upload_click(RadAsyncUpload Upload1)
|
||
{
|
||
if (Upload1.UploadedFiles.Count < 1)
|
||
{
|
||
RadAjaxManager1.Alert("未选择文件!");
|
||
return;
|
||
}
|
||
|
||
var uploadFile = Upload1.UploadedFiles[0];
|
||
/*
|
||
var extension = uploadFile.GetExtension();
|
||
var extension_list = new string[] { ".jpg", ".png", ".jpeg", ".bmp", ".gif" };
|
||
if (!extension_list.Contains(extension))
|
||
{
|
||
RadAjaxManager1.Alert("文件格式错误!");
|
||
return;
|
||
}
|
||
*/
|
||
if (BasePage.SaveFile(uploadFile, Context, out string filePath))
|
||
{
|
||
hid_url.Value = "~" + filePath;
|
||
url.Text = "~" + filePath;
|
||
}
|
||
else
|
||
{
|
||
RadAjaxManager1.Alert("上传失败!");
|
||
}
|
||
}
|
||
|
||
protected void btnRemove_Click2(object sender, EventArgs e)
|
||
{
|
||
Remove_Click();
|
||
}
|
||
|
||
/// <summary>
|
||
/// 移除软件文件
|
||
/// </summary>
|
||
public void Remove_Click()
|
||
{
|
||
if (!string.IsNullOrEmpty(hid_url.Value))
|
||
{
|
||
string path = Server.MapPath(hid_url.Value);
|
||
if (File.Exists(path))
|
||
{
|
||
File.Delete(path);
|
||
}
|
||
hid_url.Value = "";
|
||
url.Text = "";
|
||
}
|
||
}
|
||
|
||
#endregion
|
||
|
||
#region 封面图片上传下载
|
||
protected void btnUpload_Cover_Click(object sender, EventArgs e)
|
||
{
|
||
if (RadAsyncUpload_Cover.UploadedFiles.Count < 1)
|
||
{
|
||
RadAjaxManager1.Alert("未选择图片文件!");
|
||
return;
|
||
}
|
||
var uploadFile = RadAsyncUpload_Cover.UploadedFiles[0];
|
||
var arrray = Util.ConfigInfo.list_pic_type;
|
||
var extension = uploadFile.GetExtension();
|
||
if (!arrray.Contains(extension))
|
||
{
|
||
RadAjaxManager1.Alert("请上传图片!");
|
||
return;
|
||
}
|
||
|
||
if (BasePage.SaveFile(uploadFile, Context, out string filePath))
|
||
{
|
||
hid_url_pic_cover.Value = "~" + filePath;
|
||
url_pic_cover.Text = "~" + filePath;
|
||
}
|
||
else
|
||
{
|
||
RadAjaxManager1.Alert("上传失败!");
|
||
}
|
||
}
|
||
|
||
protected void btnRemove_Cover_Click(object sender, EventArgs e)
|
||
{
|
||
if (!string.IsNullOrEmpty(hid_url_pic_cover.Value))
|
||
{
|
||
string path = Server.MapPath(hid_url_pic_cover.Value);
|
||
if (File.Exists(path))
|
||
{
|
||
File.SetAttributes(path, FileAttributes.Normal);
|
||
File.Delete(path);
|
||
}
|
||
hid_url_pic_cover.Value = "";
|
||
url_pic_cover.Text = "";
|
||
}
|
||
}
|
||
#endregion
|
||
}
|
||
} |